如何使用javascript document.execcommand保存excel文件('saveas''1'null) [英] how to save excel file using javascript document.execcommand('saveas' '1' null)
本文介绍了如何使用javascript document.execcommand保存excel文件('saveas''1'null)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨我无法保存excel文件PLZ帮帮我
hi im not able to save excel file plz help me
function exportToExcel() {
//copy innerHTML of YourTable to strCopy Variable.
debugger;
var strCopy = document.getElementById("anil").outerHTML;
// clickExcel
//copy strCopy to clipboardData, this
window.clipboardData.setData("Text", strCopy);
var objExcel = new ActiveXObject("Excel.Application");
objExcel.visible = true;
var objWorkbook = objExcel.Workbooks.Add;
var objWorksheet = objWorkbook.Worksheets(1);
objWorksheet.Paste;
var element = document.getElementById("Bdy1");
if (element) {
if (document.execCommand) {
var oWin = window.open("about:blank", "_blank");
oWin.document.write(element.innerHTML);
oWin.document.close();
//objWorksheet.execCommand('SaveAs', null, 'fileName');
var success = oWin.document.execCommand('SaveAs', true, 'fileName.xls');
oWin.close();
if (!success)
alert("Sorry, your browser does not support this feature");
}
}
}
}
推荐答案
这篇关于如何使用javascript document.execcommand保存excel文件('saveas''1'null)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文