【问题标题】:export data to excel sheet将数据导出到 Excel 工作表
【发布时间】:2016-08-25 10:02:38
【问题描述】:

我使用了一些代码,其中我使用 php 将数据库表数据导出到 excel 表。但是,每当它首先下载文件时,它就会打开一个错误,即它的格式不受支持。通过单击是,它会打开并显示我的完整数据,但在最后一张表中,页脚也会显示。

代码

 <?php

 if(isset($_POST['download'])){

 // The function header by sending raw excel
 header("Content-type: application/vnd-ms-excel");

 // Defines the name of the export file "codelution-export.xls"
 header("Content-Disposition: attachment; filename=Subscribers.xls");
 ob_clean();
 // Add data table
 include 'data.php';
 }

错误

工作表错误

我想从excel表格中删除页脚以及打开文件时的错误。

【问题讨论】:

  • 试试header("Content-Type: application/vnd.ms-excel; charset=utf-8");
  • 它给出了同样的错误
  • "Content-type: application/vnd.ms-excel" 我写了这个,但没有任何改变

标签: php excel


【解决方案1】:

您可以使用库将数据库值导出到 excel
https://phpexcel.codeplex.com/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-19
    • 1970-01-01
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    • 2010-11-07
    • 2019-05-25
    • 1970-01-01
    相关资源
    最近更新 更多