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"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)