duanji1043 2016-09-12 07:03
浏览 50
已采纳

无法使用jquery和php $ _GET导出html表

my downloaded table only prints headers and does not display any content. iam following the tutorial from here:http://webslesson.blogspot.in/2016/02/export-mysql-data-to-excel-in-php-php-tutorial.html

THE FOLLOWING PLUGINS i have tried which fails to render my huge data 1.clarketm(merges rows) 2.(tried but unable to render huge dat)https://github.com/kayalshri/tableExport.jquery.plugin

my HTML DOM IS (index.php)

<div id="allTables">
    <table border="2" width="100%">
                <tr>
                    <th width="30%">Name</th>
                    <th width="20%">Activity on Code Project (%)</th>
                    <th width="10%">Activity on C# Corner (%)</th>
                    <th width="10%">Activity on Asp Forum (%)</th>
                </tr>
                <tr>
                    <td>Sibeesh</td>
                    <td>100</td>
                    <td>98</td>
                    <td>80</td>
                </tr>
                <tr>
                    <td>Ajay</td>
                    <td>90</td>
                    <td>0</td>
                    <td>50</td>
                </tr>
                    </table>
</div>
<p id="exportexcel">EXport to Excel</p>

<script>
 $(document).ready(function () {
    $('#exportexcel').click(function(){
          var excel_data = $('#allTables').html();
          console.log(excel_data);
          var page = "excel.php?data="+excel_data;
          console.log(page);
          window.location = page; // here iam sending data to excel.php through get method
 });
</script>

my excel.php file is

<?php
  header('Content-Type: application/vnd.ms-excel');
  header('Content-disposition: attachment; filename='.rand().'.xls');
  echo $_GET["data"];
?>

--please help me what iam doing wrong thanks in advance

  • 写回答

2条回答 默认 最新

  • dongyue1988 2016-09-12 07:36
    关注

    Activity on C# Corner (%) - "#" in this line is causing the problem. encoding this will resolve the issue in above code.

    But its better to use POST as suggested.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100