简体   繁体   English

html导出表从右到左excel

[英]html export table to excel right to left

I am trying to export a table to excel, I can do it but the sheet is left to right, I want it to be right to left. 我正在尝试将表格导出为ex​​cel,我可以这样做,但是表格是从左到右,我希望它从右到左。 of course I can do it manually ( Page Layout -> Sheet right-to-left ), but I want it to be automatically. 当然我可以手动完成( Page Layout -> Sheet right-to-left ),但我希望它是自动的。 I'm using for the exporting jquery.table2excel.js : 我用于导出jquery.table2excel.js

 //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 = "<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\\"><head><!--[if gte mso 9]><xml>"; e.template += "<x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions>"; e.template += "<x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>"; e.tableRows = ""; // get contents of table except for exclude $(e.element).find("tr").not(this.settings.exclude).each(function(i, o) { e.tableRows += "<tr>" + $(o).html() + "</tr>"; }); this.tableToExcel(this.tableRows, this.settings.name); }, tableToExcel: function(table, name) { var e = this; e.uri = "data:application/vnd.ms-excel;base64,"; e.base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))); }; e.format = function(s, c) { return s.replace(/{(\\w+)}/g, function(m, p) { return c[p]; }); }; e.ctx = { worksheet: name || "Worksheet", table: table }; window.location.href = e.uri + e.base64(e.format(e.template, e.ctx)); } }; $.fn[pluginName] = function(options) { this.each(function() { if (!$.data(this, "plugin_" + pluginName)) { $.data(this, "plugin_" + pluginName, new Plugin(this, options)); } }); // chain jQuery functions return this; }; })(jQuery, window, document); 

I think its something in the WorksheetOptions area, but I can't figure out what. 我认为它在WorksheetOptions区域,但我无法弄清楚是什么。

The HTML code is simple, just filling the table, and using TableSorter.js to enable sorting. HTML代码很简单,只需填充表格,并使用TableSorter.js来启用排序。

Thanks 谢谢

 <x:WorksheetOptions><x:DisplayRightToLeft/> </x:WorksheetOptions>

你可以看到更多选择: 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM