我有以下脚本。它将我的数据导出为.xls。我希望在此窗口打开时弹出一个保存对话框如何实现此目的?
function ExporttoExcel() {
var sOption = "toolbar=yes,location=no,directories=yes,menubar=yes,";
sOption += "scrollbars=yes,width=750,height=600,left=100,top=25";
var sWinHTML = document.getElementById('contentstart').innerHTML;
var winprint = window.open("", "", sOption);
winprint.document.open();
winprint.document.write('<html><head>')
winprint.document.write('<meta http-equiv="Content-Type" content="application/vnd.ms-excel">')
winprint.document.write('<meta http-equiv="Content-disposition": attachment; filename="file.xls">')
winprint.document.write('</head><body>')
winprint.document.write(sWinHTML);
winprint.document.write('</body></html>');
winprint.document.close();
winprint.focus();
}
答案 0 :(得分:1)
你可以在这个SO帖子上找到很多灵感:Export to csv in jQuery
在另一个帖子上:How to download csv file using jquery?
告诉我们您的尝试以及遇到的麻烦。