[英]PHPExcel not download or no process at all
i'm trying to export from mysql to excel using PHPExcel, i create a button to start exporting proses. 我正在尝试使用PHPExcel从mysql导出到excel,我创建了一个按钮以开始导出散文。 It's loading but return with blank white page, i check every line from the code and didn't found any problem. 它正在加载,但返回空白页,我检查了代码中的每一行,没有发现任何问题。 Calling data from table is normal, check it with echo
. 从表中调用数据是正常的,请通过echo
检查。 so i think there is a problem with exporting process, here is the code 所以我认为导出过程有问题,这是代码
require_once 'PHPExcel/PHPExcel.php';
$excel=new PHPExcel();
$excel->getProperties()->setCreator('Flora Sitinjak')
->setLastModified('Flora Sitinjak')
->setTittle('Laporan Pendapatan')
->setSubject('Pendapatan')
->setDescription('Laporan Semua Pendapatan')
->setKeywords('Data Pendapatan');
$exp=$excel->setActiveSheetIndex(0);
$exp->setCellValue('A1', "Tanggal");
$exp->setCellValue('B1', "EKS");
$exp->setCellValue('C1', "BIS");
$exp->setCellValue('D1', "EKO");
$exp->setCellValue('E1', "L.EKO");
$exp->setCellValue('F1', "Total");
$line=2;
$x=0;
for($i=1;$i<=$tgl[11];$i++){
$exp->setCellValue("A".$line, $i);
$carTL=count($arTL);
$gTGLO=substr($arTL[$x],-2);
if(empty($gTGLO)){
$x=0;
}else{
if($i==$gTGLO){
if(($x+1)>=$carTL){
$x=$carTL-1;
$exp->setCellValue("B".$line, $arLUEKS[$x]);
$exp->setCellValue("C".$line, $arLUBIS[$x]);
$exp->setCellValue("D".$line, $arUEKO[$x]);
$exp->setCellValue("E".$line, $arLEKO[$x]);
$exp->setCellValue("F".$line, $arTot[$x]);
}else{
$exp->setCellValue("B".$line, $arLUEKS[$x]);
$exp->setCellValue("C".$line, $arLUBIS[$x]);
$exp->setCellValue("D".$line, $arUEKO[$x]);
$exp->setCellValue("E".$line, $arLEKO[$x]);
$exp->setCellValue("F".$line, $arTot[$x]);
$x++;
}
}else{
$exp->setCellValue("B".$line, '-');
$exp->setCellValue("C".$line, '-');
$exp->setCellValue("D".$line, '-');
$exp->setCellValue("E".$line, '-');
$exp->setCellValue("F".$line, '-');
}
}
$line++;
}
$excel->getActiveSheet()->setTitle('Laporan');
$excel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment; filename="Data Laporan Pendapatan.xlsx');
header('Cache-Control: max-age=0');
$write=PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
$write->save('php://output');
Every array like $arLUEKS[$x]
is called from database and works, checked with echo
每个类似$arLUEKS[$x]
数组都从数据库中调用并运行,并通过echo
进行检查
The output is a table with shows data a month from 1 to 31, if the data doesn't exist then it show a -
输出是一个表格,其中显示了每月1到31的数据,如果该数据不存在,则显示-
Anyone can solve this? 任何人都可以解决吗? please help me 请帮我
I do not know what exactly could be wrong but here are some helpful things you can do that can help you identify your problem . 我不知道到底是什么错误,但是您可以执行一些有用的操作,以帮助您确定问题所在。
Turn on error reporting by adding these two to the top of your script 通过将这两个添加到脚本顶部来打开错误报告
ini_set("display_errors",1); 的ini_set( “display_errors设置”,1); error_reporting(E_ALL); 使用error_reporting(E_ALL);
This may point you to the cause. 这可能会指出原因。 Maybe the script is timing out or something 也许脚本超时了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.