出口问题 [英] problem with excell export
问题描述
我使用此 http://phpexcel.codeplex.com/ 将其导出到excel。
i use this http://phpexcel.codeplex.com/ to export to excell.
需要导出11000 - 65000行...
,但尝试执行此浏览器时挂起。
它不回答错误或其他消息。只需显示正在进行的请求。
need to export 11000 - 65000 rows... but when trying to do this browser hangs up. it do not answer with errors or other messages. just show that request in progress.
顶部显示apache已完成工作。
甚至apache日志说,所有完成:
top shows that apache finished work. even apache log says that all done:
x.x.x.x - - [28/Jul/2011:12:28:38 +0300] "POST /doctor/lab/statistic/ HTTP/1.1" 200 2773504 "http://x.x.x.x:82/doctor/lab/statistic/" "Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20100101 Firefox/5.0"
但仍然没有结果。
系统:
Linux Eearth 2.6.34-12-desktop #1 SMP PREEMPT 2010-06-29 02:39:08 +0200 i686
PHP Version 5.3.5
Apache/2.2.15 (Linux/SUSE)
所以问题
编辑1
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'.xls"');
header('Cache-Control: max-age=0');
$writer = PHPExcel_IOFactory::createWriter($xls, 'Excel5');
$writer->save('php://output');
exit;
编辑2
我试图将数据保存到这样的文件中 $ writer-> save('test.xls');
filesize 2.7MB
然后如果我这个:
i tried to save data to file like this $writer->save('test.xls');
filesize 2.7MB
then if i do this:
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'.xls"');
header('Cache-Control: max-age=0');
include 'test.xls';
exit;
下载立即开始...
推荐答案
可能您的Web服务器不会发出错误消息,所以我会说检查你的error.log(应该挂在/ var / log / apache2或类似的)。很简单就是无法写入临时文件。
It's possible that your web server is not emitting error messages, so I'd say check your error.log (should be hanging around in /var/log/apache2 or similar.) It might well be something trivial like not being able to write to a temporary file.
如果这是一个死胡同,请考虑以编程方式创建带有echo语句的CSV文件 - Excel会打开那些很好。
If that turns out as a dead-end, consider programmatically creating CSV files with echo statements - Excel will open those just fine.
编辑
要生成CSV,请执行头文件
To produce CSV, do your headers
header('Content-Type: text/comma-separated-values);
header('Content-Disposition:attachment;filename="'.$filename.'.csv"');
header('Cache-Control: max-age=0');
然后输出列标题:
echo "col1,col2,col3,col4,..."
后跟一条新行。然后输出你的数据:
followed by a new line. Then output your data:
while(/*Still got some rows*/) {
echo $row[0] . "," .$row[1] "," + ...
}
看看: http://en.wikipedia.org/wiki/Comma-separated_values,这是一个非常简单的文件格式,Excel将毫无困难地打开它。
Have a look at: http://en.wikipedia.org/wiki/Comma-separated_values, it's a really simple file format and Excel will open it without difficulty.
另一件事,我没想到的是,如果你有访问权限到Windows Server,您可以直接通过COM interop生成Excel文件。
The other thing, which I hadn't thought of, is if you've got access to a Windows Server, you can produce Excel files directly via COM interop.
这篇关于出口问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!