<?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>Export PPT &#8211; Sibeesh Passion</title>
	<atom:link href="https://mail.sibeeshpassion.com/tag/export-ppt/feed/" rel="self" type="application/rss+xml" />
	<link>https://mail.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Tue, 27 Feb 2018 06:07:32 +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>Export PPT &#8211; Sibeesh Passion</title>
	<link>https://mail.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Export From HTML Table Using jQuery</title>
		<link>https://mail.sibeeshpassion.com/export-html-table-using-jquery/</link>
					<comments>https://mail.sibeeshpassion.com/export-html-table-using-jquery/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 29 Oct 2014 18:55:52 +0000</pubDate>
				<category><![CDATA[Exporting]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Export Excel]]></category>
		<category><![CDATA[Export From HTML Table]]></category>
		<category><![CDATA[Export HTML]]></category>
		<category><![CDATA[Export PDF]]></category>
		<category><![CDATA[Export PPT]]></category>
		<category><![CDATA[Export Word]]></category>
		<category><![CDATA[JQuery Export]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=352</guid>

					<description><![CDATA[[toc] Introduction In this article, we will see how to export from an HTML table using jQuery. We all work in some applications where we are playing with data&#8217;s. It might be some data returned by the server or it might be some client-side data like HTML table. No matter whichever forms the data is, there will be an export option. Isn&#8217;t it? 80% of our clients need the data to be exported to excel. So we need to give the option to export the given data to excel, not dependent on the data format. In my case, my data [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h2>Introduction</h2>
<p>In this article, we will see how to export from an HTML table using jQuery. We all work in some applications where we are playing with data&#8217;s. It might be some data returned by the server or it might be some client-side data like HTML table. No matter whichever forms the data is, there will be an export option. Isn&#8217;t it? 80% of our clients need the data to be exported to excel. So we need to give the option to export the given data to excel, not dependent on the data format. In my case, my data is in the form of an HTML table, so in this post, we will explain how to export an HTML data to excel, pdf, png, jpeg etc. I hope you will like it.</p>
<p>Download Files here: <a href="https://code.msdn.microsoft.com/Export-From-HTML-Table-c479ff99" target="_blank" rel="noopener">HTML Table Export</a></p>
<h2>Background</h2>
<p>As I said earlier, this article explains how to export an HTML table using jQuery. In this article we will see how we can export the given data to the following formats:</p>
<ul>
<li>Excel</li>
<li>PDF</li>
<li>Image</li>
<li>CSV</li>
<li>PPT</li>
<li>Word</li>
<li>TXT</li>
<li>XML</li>
</ul>
<p>You can always see other exporting related articles here.</p>
<ul>
<li><a href="http://sibeeshpassion.com/export-hierarchical-multi-level-html-table-with-styles-using-jquery/" target="_blank" rel="noopener">Export Hierarchical (Multi-Level) HTML Table </a></li>
<li><a href="http://sibeeshpassion.com/compress-xml-string-variables-in-client-side-and-export-in-html5-using-jquery/" target="_blank" rel="noopener">Compress And Export</a></li>
</ul>
<h2><strong>Why</strong></h2>
<p>In my project, we are doing 80% of our work in the client side. So I decided to implement the export feature in the client side itself. The same can be done using server-side code also but I prefer the client-side one.</p>
<h3><strong>What you must know</strong></h3>
<ul>
<li><a href="http://jquery.com/" target="_blank" rel="noopener">jQuery</a></li>
<li><a href="http://www.w3schools.com/js/" target="_blank" rel="noopener">JavaScript</a></li>
<li><a href="http://www.w3schools.com/css/css3_intro.asp" target="_blank" rel="noopener">CSS 3</a></li>
<li><a href="http://www.w3schools.com/html/" target="_blank" rel="noopener">HTML</a></li>
<li><a href="http://www.tutorialspoint.com/jquery/jquery-dom.htm" target="_blank" rel="noopener">DOM Manipulations in jQuery</a></li>
</ul>
<h3><strong>Using the code</strong></h3>
<p>Before you start, you need to download the necessary files from <a href="https://github.com/kayalshri/tableExport.jquery.plugin" target="_blank" rel="noopener">TableExport.jquery.plugin</a>.</p>
<p>Once you have download the files, you need to include those in your project. Here I am using a MVC4 web application.</p>
<p>[js]<br />
&lt;script src=“~/Contents/jquery-1.9.1.js”&gt;&lt;/script&gt;<br />
&lt;script src=“~/Contents/tableExport.js”&gt;&lt;/script&gt; @*Main file which does export feature *@<br />
&lt;script src=“~/Contents/jquery.base64.js”&gt;&lt;/script&gt; @*Main file which does convert the content to base64 *@<br />
&lt;script src=“~/Contents/html2canvas.js”&gt;&lt;/script&gt; @*Main file which does export to image feature *@<br />
&lt;script src=“~/Contents/jspdf/libs/base64.js”&gt;&lt;/script&gt; @*Main file which does convert the content to base64 for pdf *@<br />
&lt;script src=“~/Contents/jspdf/libs/sprintf.js”&gt;&lt;/script&gt; @*Main file which does export feature for pdf *@<br />
&lt;script src=“~/Contents/jspdf/jspdf.js”&gt;&lt;/script&gt; @*Main file which does export feature for pdf *@<br />
[/js]</p>
<p>Let’s say you have an HTML table as follows:</p>
<p>[html]<br />
&lt;table id=“activity” &gt;<br />
&lt;thead&gt;<br />
&lt;tr&gt;<br />
&lt;th&gt;Name&lt;/th&gt;<br />
&lt;th&gt;Activity on Code Project (%)&lt;/th&gt;<br />
&lt;th&gt;Activity on C# Corner (%)&lt;/th&gt;<br />
&lt;th&gt;Activity on Asp Forum (%)&lt;/th&gt;<br />
&lt;/tr&gt;<br />
&lt;/thead&gt;<br />
&lt;tbody&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;Sibeesh&lt;/td&gt;<br />
&lt;td&gt;100&lt;/td&gt;<br />
&lt;td&gt;98&lt;/td&gt;<br />
&lt;td&gt;80&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;Ajay&lt;/td&gt;<br />
&lt;td&gt;90&lt;/td&gt;<br />
&lt;td&gt;0&lt;/td&gt;<br />
&lt;td&gt;50&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;Ansary&lt;/td&gt;<br />
&lt;td&gt;100&lt;/td&gt;<br />
&lt;td&gt;20&lt;/td&gt;<br />
&lt;td&gt;10&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;Aghil&lt;/td&gt;<br />
&lt;td&gt;0&lt;/td&gt;<br />
&lt;td&gt;30&lt;/td&gt;<br />
&lt;td&gt;90&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;Arya&lt;/td&gt;<br />
&lt;td&gt;0&lt;/td&gt;<br />
&lt;td&gt;0&lt;/td&gt;<br />
&lt;td&gt;95&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/tbody&gt;<br />
&lt;/table&gt;<br />
[/html]</p>
<p>Add some more UI elements for firing the click events.</p>
<p>[html]<br />
&lt;table&gt;<br />
&lt;tr id=“footerExport”&gt;<br />
&lt;td id=“exportexcel”&gt;&lt;img src=“~/icons/xls.png” title=“Export to Excel” /&gt;&lt;/td&gt;<br />
&lt;td id=“exportpdf”&gt;&lt;img src=“~/icons/pdf.png” title=“Export to PDF” /&gt;&lt;/td&gt;<br />
&lt;td id=“exportimage”&gt;&lt;img src=“~/icons/png.png” title=“Export to PNG” /&gt;&lt;/td&gt;<br />
&lt;td id=“exportcsv”&gt;&lt;img src=“~/icons/csv.png” title=“Export to CSV” /&gt;&lt;/td&gt;<br />
&lt;td id=“exportword”&gt;&lt;img src=“~/icons/word.png” title=“Export to Word” /&gt;&lt;/td&gt;<br />
&lt;td id=“exporttxt”&gt;&lt;img src=“~/icons/txt.png” title=“Export to TXT” /&gt;&lt;/td&gt;<br />
&lt;td id=“exportxml”&gt;&lt;img src=“~/icons/xml.png” title=“Export to XML” /&gt;&lt;/td&gt;<br />
&lt;td id=“exportppt”&gt;&lt;img src=“~/icons/ppt.png” title=“Export to PPT” /&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/table&gt;<br />
[/html]</p>
<p>Add a few styles to the table to make it viewable.</p>
<p>[css]<br />
&lt;style&gt;<br />
#activity {<br />
text-align:center;border:1px solid #ccc;<br />
}<br />
#activity td{<br />
text-align:center;border:1px solid #ccc;<br />
}<br />
#footerExport td{<br />
cursor:pointer;<br />
text-align:center;border:1px solid #ccc;<br />
border:none;<br />
}<br />
&lt;/style&gt;<br />
[/css]</p>
<p>Now it is time to fire our events 🙂 You can do that as in the following.<br />
[js]<br />
&lt;script&gt;<br />
$(document).ready(function () {<br />
$(‘#exportexcel’).bind(‘click’, function (e) {<br />
$(‘#activity’).tableExport({ type: ‘excel’, escape: ‘false’ });<br />
});<br />
$(‘#exportpdf’).bind(‘click’, function (e) {<br />
$(‘#activity’).tableExport({ type: ‘pdf’, escape: ‘false’ });<br />
});<br />
$(‘#exportimage’).bind(‘click’, function (e) {<br />
$(‘#activity’).tableExport({ type: ‘png’, escape: ‘false’ });<br />
});<br />
$(‘#exportcsv’).bind(‘click’, function (e) {<br />
$(‘#activity’).tableExport({ type: ‘csv’, escape: ‘false’ });<br />
});<br />
$(‘#exportppt’).bind(‘click’, function (e) {<br />
$(‘#activity’).tableExport({ type: ‘powerpoint’, escape: ‘false’ });<br />
});<br />
$(‘#exportxml’).bind(‘click’, function (e) {<br />
$(‘#activity’).tableExport({ type: ‘xml’, escape: ‘false’ });<br />
});<br />
$(‘#exportword’).bind(‘click’, function (e) {<br />
$(‘#activity’).tableExport({ type: ‘doc’, escape: ‘false’ });<br />
});<br />
$(‘#exporttxt’).bind(‘click’, function (e) {<br />
$(‘#activity’).tableExport({ type: ‘txt’, escape: ‘false’ });<br />
});<br />
});<br />
&lt;/script&gt;<br />
[/js]</p>
<p>Please note that you can export to a few more formats in the same way. You can learn more here:tableExport.jquery.plugin.</p>
<h3><strong>Explanation</strong></h3>
<p>Now its time go deeper into that plugin. In the downloaded files you can see a file called tableExport.js. just open that file, you can see some conditions for specific formats. And the default property for exporting as follows.<br />
[js]<br />
var defaults = {<br />
separator: ‘,’,<br />
ignoreColumn: [],<br />
tableName:‘yourTableName’,<br />
type:‘csv’,<br />
pdfFontSize:7,<br />
pdfLeftMargin:20,<br />
escape:‘true’,<br />
htmlContent:‘false’,<br />
consoleLog:‘false’<br />
};<br />
[/js]</p>
<p>You can change these properties depending on your needs as follows.</p>
<p>[js]<br />
var varpdfFontSize= ‘7’;<br />
$(‘#activity’).tableExport({ type: ‘excel’, escape: ‘false’,pdfFontSize:varpdfFontSize});<br />
[/js]</p>
<p>You can try all the properties listed above like this :).</p>
<p>Now in that file you can see an if else if condition that is satisfied for multiple formats. Let me explain for Excel formatting alone.</p>
<p>[js]<br />
var excel=“&lt;table&gt;”;<br />
// Header<br />
$(el).find(‘thead’).find(‘tr’).each(function() {<br />
excel += “&lt;tr&gt;”;<br />
$(this).filter(‘:visible’).find(‘th’).each(function(index,data) {<br />
if ($(this).css(‘display’) != ‘none’){<br />
if(defaults.ignoreColumn.indexOf(index) == -1){<br />
excel += “&lt;td&gt;” + parseString($(this))+ “&lt;/td&gt;”;<br />
}<br />
}<br />
});<br />
excel += ‘&lt;/tr&gt;’;<br />
});<br />
// Row Vs Column<br />
var rowCount=1;<br />
$(el).find(‘tbody’).find(‘tr’).each(function() {<br />
excel += “&lt;tr&gt;”;<br />
var colCount=0;<br />
$(this).filter(‘:visible’).find(‘td’).each(function(index,data) {<br />
if ($(this).css(‘display’) != ‘none’){<br />
if(defaults.ignoreColumn.indexOf(index) == -1){<br />
excel += “&lt;td&gt;”+parseString($(this))+“&lt;/td&gt;”;<br />
}<br />
}<br />
colCount++;<br />
});<br />
rowCount++;<br />
excel += ‘&lt;/tr&gt;’;<br />
});<br />
excel += ‘&lt;/table&gt;’<br />
if(defaults.consoleLog == ‘true’){<br />
console.log(excel);<br />
}<br />
var excelFile = “&lt;html xmlns:o=’urn:schemas-microsoft-com:office:office’ xmlns:x=’urn:schemas-microsoft-com:office:”+defaults.type+“‘ xmlns=’http://www.w3.org/TR/REC-html40′&gt;”;<br />
excelFile += “&lt;head&gt;”;<br />
excelFile += “&lt;!–[if gte mso 9]&gt;”;<br />
excelFile += “&lt;xml&gt;”;<br />
excelFile += “&lt;x:ExcelWorkbook&gt;”;<br />
excelFile += “&lt;x:ExcelWorksheets&gt;”;<br />
excelFile += “&lt;x:ExcelWorksheet&gt;”;<br />
excelFile += “&lt;x:Name&gt;”;<br />
excelFile += “{worksheet}”;<br />
excelFile += “&lt;/x:Name&gt;”;<br />
excelFile += “&lt;x:WorksheetOptions&gt;”;<br />
excelFile += “&lt;x:DisplayGridlines/&gt;”;<br />
excelFile += “&lt;/x:WorksheetOptions&gt;”;<br />
excelFile += “&lt;/x:ExcelWorksheet&gt;”;<br />
excelFile += “&lt;/x:ExcelWorksheets&gt;”;<br />
excelFile += “&lt;/x:ExcelWorkbook&gt;”;<br />
excelFile += “&lt;/xml&gt;”;<br />
excelFile += “&lt;![endif]–&gt;”;<br />
excelFile += “&lt;/head&gt;”;<br />
excelFile += “&lt;body&gt;”;<br />
excelFile += excel;<br />
excelFile += “&lt;/body&gt;”;<br />
excelFile += “&lt;/html&gt;”;<br />
var base64data = “base64,” + $.base64.encode(excelFile);<br />
window.open(‘data:application/vnd.ms-‘+defaults.type+‘;filename=exportData.doc;’ + base64data);<br />
[/js]</p>
<h3><strong>Procedure</strong></h3>
<ul>
<li>Find the UI element (in this case it is our HTML table).</li>
<li>Loop through the rows of the thread for the header information.</li>
<li>Apply a filter to avoid the UI elements that have a display as none <em>(filter(‘:visible’))</em>.</li>
<li>If the UI is visible, append it to the variable <em>(excel += “</em>” + parseString($(this))+ “”;)</li>
<li>The same procedure is done for the row vs column values also. The only difference is, here we are looping through the tbody instead of thread.</li>
<li>After the data is manipulated, data is formulated in the Excel format.</li>
</ul>
<p>You can learn more in the attachment.</p>
<h2><strong>Output</strong></h2>
<div id="attachment_10926" style="width: 300px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2014/10/export.png"><img decoding="async" aria-describedby="caption-attachment-10926" class="size-full wp-image-10926" src="http://sibeeshpassion.com/wp-content/uploads/2014/10/export.png" alt="Export From HTML Table" width="290" height="100" /></a><p id="caption-attachment-10926" class="wp-caption-text">Export From HTML Table</p></div>
<h2><strong>Points of Interest</strong></h2>
<p>jquery, CSS, HTML, Export</p>
<h2><strong>History</strong></h2>
<p>1st version: 18-11-2014<br />
2nd Version: 24-11-2014</p>
<h2><strong>Changes did</strong></h2>
<ol>
<li>Added Images to UI elements</li>
<li>Added some export feature</li>
</ol>
<h2><strong>Conclusion</strong></h2>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<h2><strong>Your turn. What do you think?</strong></h2>
<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.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/export-html-table-using-jquery/feed/</wfw:commentRss>
			<slash:comments>135</slash:comments>
		
		
			</item>
	</channel>
</rss>
