将数据导出到Excel时如何更改文件的名称? [英] How to change the name of file while exporting data to Excel?

查看:152
本文介绍了将数据导出到Excel时如何更改文件的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < div id =exampleclass 

如何在将数据导出到Excel时更改文件名? = K-内容 >
< button type =buttonid =btnExport>导出到csv!< / button>
< div id =grid>< / div>
< / div>
< script>
$(#btnExport)。click(function(e){
var result =data:application / vnd.ms-excel,;

window.open (result);

e.preventDefault();
});
< / script>

当我点击导出按钮时,我得到的是download.xls。是否可以将文件名设置为data.xls?任何人可以解释我在哪里需要配置?



谢谢

解决方案

下面是一个演示如何使用自定义文件名将HTML表格导出为Excel的示例: http://www.kubilayerdogan.net/javascript-export-html-table-to-excel-with-custom-file-name/


How do I change the name of file while exporting data to Excel?

<div id="example" class="k-content">
    <button type="button"id="btnExport">Export to csv!</button>
    <div id="grid"></div>
</div>
<script>
$("#btnExport").click(function (e) {
    var result = "data:application/vnd.ms-excel,";

    window.open(result);

    e.preventDefault();
});
</script>

When I click the export button I am getting as download.xls. Is it possible to set the file name as data.xls? Can any one explain me where I need to configure that?

Thanks

解决方案

here is an example which demonstrates Export HTML Table to Excel With Custom File Name: http://www.kubilayerdogan.net/javascript-export-html-table-to-excel-with-custom-file-name/

这篇关于将数据导出到Excel时如何更改文件的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆