<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HTML &#8211; Sibeesh Passion</title>
	<atom:link href="https://www.sibeeshpassion.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Tue, 29 Sep 2015 09:00:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>HTML &#8211; Sibeesh Passion</title>
	<link>https://www.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Check for any unsaved changes in page</title>
		<link>https://www.sibeeshpassion.com/check-for-any-unsaved-changes-in-page/</link>
					<comments>https://www.sibeeshpassion.com/check-for-any-unsaved-changes-in-page/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Tue, 29 Sep 2015 00:04:14 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Check for any unsaved changes in page]]></category>
		<category><![CDATA[Show alert when there is unsaved changes]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10714</guid>

					<description><![CDATA[In this post we will discuss how we can check for any unsaved changes in the page by using JQuery. Normally this may need to be implemented in an application where we need to give any alert if any user try to reload the page when there any unsaved changes in the page. I hope you will like this. Background I was creating a page where I have some text boxes, So I wanted to give an alert if user try to get away from the page with out saving the data entered. Using the code First of all we [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will discuss how we can check for any unsaved changes in the page by using <a href="http://sibeeshpassion.com/tag/JQuery/" target="_blank">JQuery</a>. Normally this may need to be implemented in an application where we need to give any alert if any user try to reload the page when there any unsaved changes  in the page. I hope you will like this. </p>
<p><strong>Background</strong></p>
<p>I was creating a page where I have some text boxes, So I wanted to give an alert if user try to get away from the page with out saving the data entered. </p>
<p><strong>Using the code</strong></p>
<p>First of all we will create a page and a html table.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Check for any unsaved changes in page&lt;/title&gt;<br />
    &lt;script src=&quot;jquery-2.0.2.min.js&quot;&gt;&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;table class=&quot;table&quot; border=&quot;1&quot; style=&quot;width: 40%&quot;&gt;<br />
        &lt;tr&gt;<br />
            &lt;td&gt;Sibi&lt;/td&gt;<br />
            &lt;td&gt;Ajay&lt;/td&gt;<br />
            &lt;td&gt;&lt;input class=&quot;text&quot; type=&quot;text&quot;  /&gt;&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
        &lt;tr&gt;<br />
            &lt;td&gt;Ansu&lt;/td&gt;<br />
            &lt;td&gt;Akhil&lt;/td&gt;<br />
            &lt;td&gt;&lt;input class=&quot;text&quot; type=&quot;text&quot; /&gt;&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
        &lt;tr&gt;<br />
            &lt;td&gt;Shanto&lt;/td&gt;<br />
            &lt;td&gt;Libin&lt;/td&gt;<br />
            &lt;td&gt;&lt;input class=&quot;text&quot; type=&quot;text&quot; /&gt;&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
    &lt;/table&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p>Now if you run your page and, you can see the table.</p>
<div id="attachment_10716" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_11-e1443423241572.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-10716" src="http://sibeeshpassion.com/wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_11-e1443423241572.png" alt="Check for any unsaved changes in page" width="650" height="83" class="size-full wp-image-10716" srcset="/wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_11-e1443423241572.png 650w, /wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_11-e1443423241572-300x38.png 300w, /wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_11-e1443423241572-400x51.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-10716" class="wp-caption-text">Check for any unsaved changes in page</p></div>
<p>No we will create a bool variable which will be true when there is an unsaved data.</p>
<p>[js]<br />
var unsaved = false;<br />
[/js]</p>
<p>What next? We will add call to an existing function when user reloads the page. Sounds good?</p>
<p>[js]<br />
window.onbeforeunload = unloadPage;<br />
[/js]</p>
<p>As you can see we are calling a function <em>unloadPage</em>, preceding is the function definition.</p>
<p>[js]<br />
 function unloadPage() {<br />
            if (unsaved) {<br />
                return &quot;You have unsaved changes on this page.&quot;;<br />
            }<br />
        }<br />
[/js]</p>
<p>Now please run your page and type anything in the text box given, then reload your page.<br />
You will get an alert of <em>You have unsaved changes on this page.</em>. Shall we check that?</p>
<div id="attachment_10717" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_2-e1443423675762.png"><img decoding="async" aria-describedby="caption-attachment-10717" src="http://sibeeshpassion.com/wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_2-e1443423675762.png" alt="Check for any unsaved changes in page" width="650" height="260" class="size-full wp-image-10717" srcset="/wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_2-e1443423675762.png 650w, /wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_2-e1443423675762-300x120.png 300w, /wp-content/uploads/2015/09/Check_for_any_unsaved_changes_in_page_2-e1443423675762-400x160.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-10717" class="wp-caption-text">Check for any unsaved changes in page</p></div>
<p>We have done it finally.</p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Check for any unsaved changes in page&lt;/title&gt;<br />
    &lt;script src=&quot;jquery-2.0.2.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var unsaved = false;<br />
        $(document).on(&#8216;change&#8217;, &#8216;.table .text&#8217;, function () {<br />
            unsaved = true;<br />
        });</p>
<p>        $(document).on(&#8216;mouseover&#8217;, &#8216;.table td&#8217;, function () {<br />
            $(this).attr(&#8216;title&#8217;, $(this).text());<br />
        });<br />
        function unloadPage() {<br />
            if (unsaved) {<br />
                return &quot;You have unsaved changes on this page.&quot;;<br />
            }<br />
        }<br />
        window.onbeforeunload = unloadPage;<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;table class=&quot;table&quot; border=&quot;1&quot; style=&quot;width: 40%&quot;&gt;<br />
        &lt;tr&gt;<br />
            &lt;td&gt;Sibi&lt;/td&gt;<br />
            &lt;td&gt;Ajay&lt;/td&gt;<br />
            &lt;td&gt;<br />
                &lt;input class=&quot;text&quot; type=&quot;text&quot; /&gt;&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
        &lt;tr&gt;<br />
            &lt;td&gt;Ansu&lt;/td&gt;<br />
            &lt;td&gt;Akhil&lt;/td&gt;<br />
            &lt;td&gt;<br />
                &lt;input class=&quot;text&quot; type=&quot;text&quot; /&gt;&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
        &lt;tr&gt;<br />
            &lt;td&gt;Shanto&lt;/td&gt;<br />
            &lt;td&gt;Libin&lt;/td&gt;<br />
            &lt;td&gt;<br />
                &lt;input class=&quot;text&quot; type=&quot;text&quot; /&gt;&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
    &lt;/table&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Have you ever faced this requirement in your programming life? Does this article helps you in anyway? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can. Have a happy coding!.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/check-for-any-unsaved-changes-in-page/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Export Hierarchical (Multi-Level) HTML Table With Styles Using jQuery</title>
		<link>https://www.sibeeshpassion.com/export-hierarchical-multi-level-html-table-with-styles-using-jquery/</link>
					<comments>https://www.sibeeshpassion.com/export-hierarchical-multi-level-html-table-with-styles-using-jquery/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Thu, 13 Aug 2015 00:13:42 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Export HTML]]></category>
		<category><![CDATA[Export multi level table]]></category>
		<category><![CDATA[Export table]]></category>
		<category><![CDATA[Hierarchical HTML]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Multi Level HTML]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=501</guid>

					<description><![CDATA[Introduction Hi. We are all familiar with HTML tables. What if we want to export that HTML table to Excel? What if we want to do it in the client side itself? Yeah, of course using jQuery. Please read here for the basic exporting technique: Export From HTML Table Using jQuery. Background In the preceding article you can determine whether we are exporting a single-level HTML table. What if we need to do that for a multi-level HTML table? The hierarchy must be applied to the Excel file we exported. That too is without using any third-party plug- ins! Sounds [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span style="color: #ff6600;">Introduction</span></p>
<p>Hi. We are all familiar with HTML tables. What if we want to export that HTML table to Excel? What if we want to do it in the client side itself? Yeah, of course using jQuery. Please read here for the basic exporting technique: Export From HTML Table Using jQuery.</p>
<p><span style="color: #ff6600;">Background</span></p>
<p>In the preceding article you can determine whether we are exporting a single-level HTML table. What if we need to do that for a multi-level HTML table? The hierarchy must be applied to the Excel file we exported. That too is without using any third-party plug- ins! Sounds cool, right?</p>
<p><span style="color: #ff6600;">Using the code</span></p>
<p>So shall we start? I hope you said yes.</p>
<p><span style="color: #ff6600;">What we need first</span></p>
<p>Yeah you are right, we need a multi-level HTML table that we will now export. Let us say I have an HTML table as follows.<br />
[html]<br />
&lt;table id=“multiLevelTable”&gt;<br />
        &lt;caption&gt;My Multi Level Table&lt;/caption&gt;<br />
        &lt;thead&gt;<br />
            &lt;tr&gt;<br />
                &lt;th colspan=“2” rowspan=“2”&gt;Column 0&lt;/th&gt;<br />
                &lt;th rowspan=“2”&gt;Column 1&lt;/th&gt;<br />
                &lt;th colspan=“2”&gt;Column 2&lt;/th&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;th&gt;Column 2a&lt;/th&gt;<br />
                &lt;th&gt;Column 2b&lt;/th&gt;<br />
            &lt;/tr&gt;<br />
        &lt;/thead&gt;<br />
        &lt;tbody&gt;<br />
            &lt;tr&gt;<br />
                &lt;th rowspan=“2”&gt;Row 1&lt;/th&gt;<br />
                &lt;th&gt;Row 1a&lt;/th&gt;<br />
                &lt;td&gt;123&lt;/td&gt;<br />
                &lt;td&gt;456&lt;/td&gt;<br />
                &lt;td&gt;789&lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;th&gt;Row 1b&lt;/th&gt;<br />
                &lt;td&gt;123&lt;/td&gt;<br />
                &lt;td&gt;456&lt;/td&gt;<br />
                &lt;td&gt;789&lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;th colspan=“2”&gt;Row 2&lt;/th&gt;<br />
                &lt;td&gt;123&lt;/td&gt;<br />
                &lt;td&gt;456&lt;/td&gt;<br />
                &lt;td&gt;789&lt;/td&gt;<br />
            &lt;/tr&gt;<br />
        &lt;/tbody&gt;<br />
    &lt;/table&gt;<br />
[/html]</p>
<p>What next?</p>
<p><span style="color: #ff6600;">Apply some styles</span></p>
<p>Please add the following styles.<br />
[css]<br />
&lt;style&gt;<br />
    td,th,thead,caption,tr{<br />
        text-align:center;border:1px solid #ccc;<br />
    }<br />
        caption {<br />
            background-color:#ccc;<br />
        }<br />
[/css]</p>
<p>Is that done?</p>
<p><span style="color: #ff6600;">Add the jQuery reference</span><br />
[js]<br />
&lt;script src=“Contents/jquery-1.9.1.js”&gt;&lt;/script&gt;<br />
[/js]</p>
<p><span style="color: #ff6600;">Create an element on which we need to fire the click event.<br />
[html]<br />
&lt;div onclick=“exportThis()” style=“cursor: pointer; border: 1px solid #ccc; text-align: center;width:19%;”&gt;Export Multi Level Table to Excel&lt;/div&gt;<br />
[/html]</p>
<p>Please note that we have called the function exportThis in onclick. Shall we go and see what we can write in that function?</p>
<p><span style="color: #ff6600;">exportThis function</span></p>
<p>The following is the code inside in the function.<br />
[js]<br />
var exportThis = (function () {<br />
            var uri = ‘data:application/vnd.ms-excel;base64,’,<br />
template = ‘&lt;html xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:x=”urn:schemas-microsoft-com:office:excel”  xmlns=”http://www.w3.org/TR/REC-html40″&gt;&lt;head&gt; &lt;!–[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt; &lt;x:ExcelWorksheet&gt;&lt;x:Name&gt;{worksheet}&lt;/x:Name&gt; &lt;x:WorksheetOptions&gt;&lt;x:DisplayGridlines/&gt;&lt;/x:WorksheetOptions&gt; &lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt;&lt;/x:ExcelWorkbook&gt; &lt;/xml&gt;&lt;![endif]–&gt;&lt;/head&gt;&lt;body&gt; &lt;table&gt;{table}&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;’,<br />
                base64 = function (s) {<br />
                    return window.btoa(unescape(encodeURIComponent(s)))<br />
                },<br />
                format = function (s, c) {<br />
                    return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; })<br />
                }<br />
            return function () {<br />
                var ctx = { worksheet: ‘Multi Level Export Table Example’ || ‘Worksheet’, table: document.getElementById(“multiLevelTable”).innerHTML }<br />
                window.location.href = uri + base64(format(template, ctx))<br />
            }<br />
        })()<br />
[/js]</p>
<p>In the preceding specified function, you can see the following three parts:</p>
<li>Uri</li>
<li>base64</li>
<li>format</li>
<li>template</li>
<p>So we will discuss those terms now.</p>
<p>If you are confused about the terms URI and URL please read here: <a href="http://stackoverflow.com/questions/4913343/what-is-the-difference-between-uri-url-and-urn" target="_blank">What is the difference between URI, URL and URN?</a></p>
<p>To be familiar with the base 64 encoding please read: <a href="http://stackoverflow.com/questions/201479/what-is-base-64-encoding-used-for" target="_blank">What is base 64 encoding used for?</a></p>
<p>The format part is cross-checking the data, whether it has some invalid characters or not. You can see a regex in the function.</p>
<p>The template is the structure of the Excel file; we are using the w3 format.</p>
<p><span style="color: #ff6600;">What it does</span></p>
<p>Once we clicked the div, the onclick event will be fired and it fetches the inner HTML of the element multiLevelTable. Once it does, we are formulating the data and assigning it to the location.href().</p>
<p>Please see here to understand the basic difference between the window.location.href() and window.open() : Window.location.href () and Window.open () methods in JavaScript.</p>
<p>Wow cool, we did it.</p>
<div id="attachment_9491" style="width: 371px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2014/11/Export-Hierarchical-HTML-Table1.jpg"><img decoding="async" aria-describedby="caption-attachment-9491" src="http://sibeeshpassion.com/wp-content/uploads/2014/11/Export-Hierarchical-HTML-Table1.jpg" alt="Export Hierarchical HTML Table" width="361" height="154" class="size-full wp-image-9491" srcset="/wp-content/uploads/2014/11/Export-Hierarchical-HTML-Table1.jpg 361w, /wp-content/uploads/2014/11/Export-Hierarchical-HTML-Table1-300x128.jpg 300w" sizes="(max-width: 361px) 100vw, 361px" /></a><p id="caption-attachment-9491" class="wp-caption-text">Export Hierarchical HTML Table</p></div>
<p>Figure: without style.</p>
<div id="attachment_9492" style="width: 364px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2014/11/Export-Hierarchical-HTML-Table2.jpg"><img decoding="async" aria-describedby="caption-attachment-9492" src="http://sibeeshpassion.com/wp-content/uploads/2014/11/Export-Hierarchical-HTML-Table2.jpg" alt="Export Hierarchical HTML Table" width="354" height="144" class="size-full wp-image-9492" srcset="/wp-content/uploads/2014/11/Export-Hierarchical-HTML-Table2.jpg 354w, /wp-content/uploads/2014/11/Export-Hierarchical-HTML-Table2-300x122.jpg 300w" sizes="(max-width: 354px) 100vw, 354px" /></a><p id="caption-attachment-9492" class="wp-caption-text">Export Hierarchical HTML Table</p></div>
<p>Figure: with style</p>
<p>Wait, we are not done yet</p>
<p>Now what if you have many HTML tables and you may need to export all the HTML tables? Of course we cannot create separate functions, right?</p>
<p>So can we do some changes to our function?</p>
<p>Let us do this.</p>
<p><span style="color: #ff6600;">New export function</span><br />
[js]<br />
var exportThisWithParameter = (function () {<br />
            var uri = ‘data:application/vnd.ms-excel;base64,’, template = ‘&lt;html xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:x=”urn:schemas-microsoft-com:office:excel”  xmlns=”http://www.w3.org/TR/REC-html40″&gt;&lt;head&gt; &lt;!–[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt; &lt;x:ExcelWorksheet&gt;&lt;x:Name&gt;{worksheet}&lt;/x:Name&gt; &lt;x:WorksheetOptions&gt;&lt;x:DisplayGridlines/&gt;&lt;/x:WorksheetOptions&gt; &lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt;&lt;/x:ExcelWorkbook&gt; &lt;/xml&gt;&lt;![endif]–&gt;&lt;/head&gt;&lt;body&gt; &lt;table&gt;{table}&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;’,<br />
                base64 = function (s) {<br />
                    return window.btoa(unescape(encodeURIComponent(s)))<br />
                },<br />
                format = function (s, c) {<br />
                    return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; })<br />
                }<br />
            return function (tableID, excelName) {<br />
                tableID = document.getElementById(tableID)<br />
                var ctx = { worksheet: excelName || ‘Worksheet’, table: tableID.innerHTML }<br />
                window.location.href = uri + base64(format(template, ctx))<br />
            }<br />
        })()<br />
[/js]</p>
<p>In the preceding function you can see the parameters (tableID, excelName) . This is what we need to pass from the click event as follows.<br />
[html]<br />
&lt;div onclick=“exportThisWithParameter(‘multiLevelTable’, ‘Multi Level Export Table Example’)” style=“cursor: pointer; border: 1px solid #ccc; text-align: center;width:19%;”&gt;Export Multi Level Table to Excel With Parameter&lt;/div&gt;<br />
[/html]</p>
<p><span style="color: #ff6600;">Complete HTML</span><br />
[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html xmlns=“http://www.w3.org/1999/xhtml”&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Export Hierarchical HTML Using JQuery – Sibeesh|Passion&lt;/title&gt;<br />
    &lt;script src=“Contents/jquery-1.9.1.js”&gt;&lt;/script&gt;<br />
    &lt;style&gt;<br />
    td,th,thead,caption,tr{<br />
        text-align:center;border:1px solid #ccc;<br />
    }<br />
        caption {<br />
            background-color:#ccc;<br />
        }<br />
&lt;/style&gt;<br />
    &lt;script type=“text/javascript”&gt;<br />
        var exportThis = (function () {<br />
            var uri = ‘data:application/vnd.ms-excel;base64,’,<br />
                template = ‘&lt;html xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:x=”urn:schemas-microsoft-com:office:excel”  xmlns=”http://www.w3.org/TR/REC-html40″&gt;&lt;head&gt; &lt;!–[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt; &lt;x:ExcelWorksheet&gt;&lt;x:Name&gt;{worksheet}&lt;/x:Name&gt; &lt;x:WorksheetOptions&gt;&lt;x:DisplayGridlines/&gt;&lt;/x:WorksheetOptions&gt; &lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt;&lt;/x:ExcelWorkbook&gt; &lt;/xml&gt;&lt;![endif]–&gt;&lt;/head&gt;&lt;body&gt; &lt;table&gt;{table}&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;’,<br />
                base64 = function (s) {<br />
                    return window.btoa(unescape(encodeURIComponent(s)))<br />
                },<br />
                format = function (s, c) {<br />
                    return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; })<br />
                }<br />
            return function () {<br />
                var ctx = { worksheet: ‘Multi Level Export Table Example’ || ‘Worksheet’, table: document.getElementById(“multiLevelTable”).innerHTML }<br />
                window.location.href = uri + base64(format(template, ctx))<br />
            }<br />
        })()<br />
        var exportThisWithParameter = (function () {<br />
            var uri = ‘data:application/vnd.ms-excel;base64,’,<br />
                template = ‘&lt;html xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:x=”urn:schemas-microsoft-com:office:excel”  xmlns=”http://www.w3.org/TR/REC-html40″&gt;&lt;head&gt; &lt;!–[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt; &lt;x:ExcelWorksheet&gt;&lt;x:Name&gt;{worksheet}&lt;/x:Name&gt; &lt;x:WorksheetOptions&gt;&lt;x:DisplayGridlines/&gt;&lt;/x:WorksheetOptions&gt; &lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt;&lt;/x:ExcelWorkbook&gt; &lt;/xml&gt;&lt;![endif]–&gt;&lt;/head&gt;&lt;body&gt; &lt;table&gt;{table}&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;’,<br />
                base64 = function (s) {<br />
                    return window.btoa(unescape(encodeURIComponent(s)))<br />
                },<br />
                format = function (s, c) {<br />
                    return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; })<br />
                }<br />
            return function (tableID, excelName) {<br />
                tableID = document.getElementById(tableID)<br />
                var ctx = { worksheet: excelName || ‘Worksheet’, table: tableID.innerHTML }<br />
                window.location.href = uri + base64(format(template, ctx))<br />
            }<br />
        })()<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;div onclick=“exportThis()” style=“cursor: pointer; border: 1px solid #ccc; text-align: center;width:19%;”&gt;Export Multi Level Table to Excel&lt;/div&gt;<br />
    &lt;br /&gt;<br />
    &lt;div onclick=“exportThisWithParameter(‘multiLevelTable’, ‘Multi Level Export Table Example’)” style=“cursor: pointer; border: 1px solid #ccc; text-align: center;width:19%;”&gt;Export Multi Level Table to Excel With Parameter&lt;/div&gt;<br />
    &lt;br /&gt;<br />
    &lt;br /&gt;<br />
    &lt;table id=“multiLevelTable”&gt;<br />
        &lt;caption&gt;My Multi Level Table&lt;/caption&gt;<br />
        &lt;thead&gt;<br />
            &lt;tr&gt;<br />
                &lt;th colspan=“2” rowspan=“2” style=“background-color:aqua;”&gt;Column 0&lt;/th&gt;<br />
                &lt;th rowspan=“2”&gt;Column 1&lt;/th&gt;<br />
                &lt;th colspan=“2”&gt;Column 2&lt;/th&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;th&gt;Column 2a&lt;/th&gt;<br />
                &lt;th&gt;Column 2b&lt;/th&gt;<br />
            &lt;/tr&gt;<br />
        &lt;/thead&gt;<br />
        &lt;tbody&gt;<br />
            &lt;tr&gt;<br />
                &lt;th rowspan=“2”&gt;Row 1&lt;/th&gt;<br />
                &lt;th&gt;Row 1a&lt;/th&gt;<br />
                &lt;td&gt;123&lt;/td&gt;<br />
                &lt;td&gt;456&lt;/td&gt;<br />
                &lt;td&gt;789&lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;th&gt;Row 1b&lt;/th&gt;<br />
                &lt;td&gt;123&lt;/td&gt;<br />
                &lt;td&gt;456&lt;/td&gt;<br />
                &lt;td&gt;789&lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;th colspan=“2”&gt;Row 2&lt;/th&gt;<br />
                &lt;td&gt;123&lt;/td&gt;<br />
                &lt;td&gt;456&lt;/td&gt;<br />
                &lt;td&gt;789&lt;/td&gt;<br />
            &lt;/tr&gt;<br />
        &lt;/tbody&gt;<br />
    &lt;/table&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><span style="color: #ff6600;">Points of interests</span></p>
<p>Hierarchical HTML, HTML, JQuery, Multi Level HTML</p>
<p><span style="color: #ff6600;">History</span></p>
<p>First Version : 19-Jan-2015</p>
<p><span style="color: #ff6600;">Conclusion</span></p>
<p>That is all for the day. I hope you enjoyed this article. Thanks for reading. Please provide your valuable suggestions.</p>
<p>Kindest Regards<br />
<a href="http://sibeeshpassion.com" target="_blank">Sibeesh Venu</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/export-hierarchical-multi-level-html-table-with-styles-using-jquery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
