我正在使用filesaver.js
将我的div(带有多个表)导出为excel。我可以使用下面的代码将其导出为XLS。
var blob = new Blob([document.getElementById('exportable').innerHTML], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
});
saveAs(blob, "Test Report using FileSaver.xls");
但是,我想将我的div导出到XLSX。有人可以帮忙吗?我尝试将MIME类型更改为XLSX,但没有帮助。
答案 0 :(得分:1)
<强>更新强>
W3C没有实现Would you like overnight delivery [Y/N]? Y
Today's Date: 03-25-2017
Your Expected Arrival Date: 03-26-2017
Would you like overnight delivery [N/Y]? N
Today's Date: 03-25-2017
Your Expected Arrival Date: 03-28-2017
所以浏览器也是如此。但您可以使用.xlsx
js库将数据导出为有效alsql
,此处为jsfiddle或在代码下运行
.xlsx
&#13;
function myCtrl($scope) {
$scope.exportData = function () {
alasql('SELECT * INTO XLSX("Report.xlsx",{headers:true}) FROM ?',[$scope.items]);
};
$scope.items = [{
name: "John Smith",
email: "j.smith@example.com",
dob: "1985-10-10"
}, {
name: "Jane Smith",
email: "jane.smith@example.com",
dob: "1988-12-22"
}, {
name: "Jan Smith",
email: "jan.smith@example.com",
dob: "2010-01-02"
}, {
name: "Jake Smith",
email: "jake.smith@exmaple.com",
dob: "2009-03-21"
}, {
name: "Josh Smith",
email: "josh@example.com",
dob: "2011-12-12"
}, {
name: "Jessie Smith",
email: "jess@example.com",
dob: "2004-10-12"
}];
};
&#13;