Click here to Skip to main content
15,910,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi im not able to save excel file plz help me




C#
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");
                   }
               }


}
Posted
Comments
What is the exact issue? Did you debug?
kumar9avinash 25-Apr-14 4:36am    
im getting file not supporting error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900