Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
following code

XML
<script type="text/javascript">
        var tableToExcel = (function () {
            var uri = 'data:application/vnd.ms-excel;base64,'
                , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
                , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
                , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) {return c[p]; }) }
            return function (table, name) {

                if (!table.nodeType) table = document.getElementById(table)
                var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }

                //alert(uri + base64(format(template, ctx)));
                //alert(base64(format(template, ctx)));
                window.location.href =uri + base64(format(template, ctx))

            }
        })()

    </script>




I have to save my dynamic created excel file in D Drive please help me

Thank You
Posted

1 solution

Hi
This might not be perfect, but check this source here to export a table to excel on button click, perhaps you can then include that code event in yours to export. Just a thought...

https://github.com/jmaister/excellentexport[^]
 
Share this answer
 
Comments
hareshdgr8 16-May-15 1:52am    
I never understand how to use github code

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