jsPDF playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js"></script>
<script src="https://github.com/sphilee/jsPDF-CustomFonts-support/blob/master/dist/jspdf.customfonts.min.js"></script>
<script src="https://github.com/sphilee/jsPDF-CustomFonts-support/blob/master/dist/default_vfs.js"></script>
<script src="https://unpkg.com/[email protected]/dist/jspdf.plugin.autotable.js"></script>
<button id="get-pdf">
Get PDF
</button>
<button id="toexcel">
To excel
</button>
<!-- <iframe width="100%" height="100%" id="preview" frameborder="0"></iframe> -->
<table id="tabtabtab">
<thead>
<tr>
<td>тестирование for Russian</td>
<td>اختبارات for arabic</td>
<td>পরীক্ষামূলক for Bangla</td>
<td>pengujian for indonesian</td>
</tr>
</thead>
<tbody>
<tr>
<td>column1</td>
<td>column2</td>
<td>column3</td>
<td>column4</td>
</tr>
<tr>
<td>column1</td>
<td>column2</td>
<td>column3</td>
<td>column4</td>
</tr>
<tr>
<td>column1</td>
<td>column2</td>
<td>column3</td>
<td>column4</td>
</tr>
</tbody>
</table>
JavaScript
//table2excel.js
;(function ( $, window, document, undefined ) {
var pluginName = "table2excel",
defaults = {
exclude: ".noExl",
name: "Table2Excel"
};
// The actual plugin constructor
function Plugin ( element, options ) {
this.element = element;
// jQuery has an extend method which merges the contents of two or
// more objects, storing the result in the first object. The first object
// is generally empty as we don't want to alter the default options for
// future instances of the plugin
//
this.settings = $.extend( {}, defaults, options );
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Plugin.prototype = {
init: function () {
var e = this;
e.template = {
head: "<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\"><meta http-equiv=\"content-type\" content=\"application/vnd.ms-excel; charset=UTF-8\"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets>",
sheet: {
head: "<x:ExcelWorksheet><x:Name>",
tail: "</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>"
},
mid: "</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>",
table: {
head: "<table>",
tail: "</table>"
},
foot: "</body></html>"
};
e.tableRows = [];
// get contents of table except for exclude
$(e.element).each( function(i,o) {
var tempRows = "";
$(o).find("tr").not(e.settings.exclude).each(function (i,o) {
tempRows += "<tr>" +...