我正在使用 jQueryplugin https://github.com/battatech/battatech_excelexport将 HTML 表导出到 Excel。使用chrome下载的文件名始终是download.xls
使用 mozilla firefox 是random-string.xls
。我希望根据日期创建文件名。例如23-06-2014.xls
.
下面是视图文件中的自定义 JS 块
$(document).ready(function () {
$("#btnExport").click(function () {
$("#account_table").btechco_excelexport({
containerid: "account_table",
datatype: $datatype.Table
});
});
});
您想要设置download
and href
链接上的属性。例如
$("#btnExport").click(function () {
var uri = $("#account_table").btechco_excelexport({
containerid: "account_table",
datatype: $datatype.Table,
returnUri: true
});
$(this).attr('download', 'ExportToExcel.xls') // set file name (you want to put formatted date here)
.attr('href', uri) // data to download
.attr('target', '_blank') // open in new window (optional)
;
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)