admin管理员组文章数量:1391951
I am trying to export div data which using JavaScript. It is exported to Excel but without css. No border is showing in Excel format, even I am not able to give name of Excel file.
Here is my code:
function ExportToExcel() {
var contents = $(".divclass").html();
window.open('data:application/vnd.ms-excel,' + encodeURIComponent(contents));
}
I am trying to export div data which using JavaScript. It is exported to Excel but without css. No border is showing in Excel format, even I am not able to give name of Excel file.
Here is my code:
function ExportToExcel() {
var contents = $(".divclass").html();
window.open('data:application/vnd.ms-excel,' + encodeURIComponent(contents));
}
Share
Improve this question
edited Jul 31, 2017 at 13:47
hbulens
1,9693 gold badges24 silver badges51 bronze badges
asked Jul 31, 2017 at 13:09
SujeetSujeet
211 gold badge1 silver badge2 bronze badges
1
- 2 and your div is posed of? – Prabhakaran Commented Jul 31, 2017 at 13:12
1 Answer
Reset to default 2$("#btnExport").click(function(e) {
let file = new Blob([$('.divclass').html()], {type:"application/vnd.ms-excel"});
let url = URL.createObjectURL(file);
let a = $("<a />", {
href: url,
download: "filename.xls"}).appendTo("body").get(0).click();
e.preventDefault();
});
本文标签: Export To Excel a div content using JavascriptJqueryStack Overflow
版权声明:本文标题:Export To Excel a div content using JavascriptJquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744733871a2622207.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论