我想知道是否有可能创建一个Excel文件,并使其从一个网页下载与javascript?
目前,我成功地创建了一个。csv,并用以下代码下载了它:
var blob = new Blob([csvText], { type: 'text/csv;charset=UFT-8;' });
var link = document.createElement("a");
if (link.download !== undefined) { // feature detection
// Browsers that support HTML5 download attribute
var url = URL.createObjectURL(blob);
link.setAttribute("href", url);
link.setAttribute("download", "file.csv");
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
我想知道在javascript中是否有任何库允许将文件从csv格式转换为xlsx格式,并使其以与csv相同的方式下载?
最终目的是在下划线的XLSX中设置模板。
有两个选项https://github.com/stephenliberty/excel-builder.js
另一个使用较少Excel选项但较少担心Excel兼容性问题的github项目可以在这里找到:explorentexport.js https://github.com/jmaister/explorentexport