Export datagrid to excel using Jquery Easyui

前端 未结 2 1839
广开言路
广开言路 2020-12-28 11:37

I am new in json. I generated jason data from mysql table using php and want to export the generated json to .xls format.

examexport.php



        
相关标签:
2条回答
  • 2020-12-28 11:44

    In your examexport.php, change $_POST to $_GET and use the following function:

    <input type="button" onclick="exportExcel()" value="Export to Excel " />
    <script>
        function exportExcel() {
            var row=$('#dg').datagrid('getData');//to get the loaded data
            if (row) {
                url = "excel/examexport.php?entry="+$('#entry').val()+"&
                       semester="+$('#semester').val()+"&batch="+$('#batch').val();
                window.open(url);
                }
        }
     </script>
    

    For final word, please go through http://www.jeasyui.com/documentation/index.php. they have good documentation.

    0 讨论(0)
  • $("#btnExport").click(function(e) {
    window.open('data:application/vnd.ms-excel,' + encodeURIComponent($('#dg').html()));
    e.preventDefault(); });
    

    you can use just simple jquery code. you should add jquery library on your file.​

    0 讨论(0)
提交回复
热议问题