问题描述
我正在使用PHPExcel 1.7.9版.
I'm using PHPExcel version 1.7.9.
这是我的PHP代码:
$temp_name = $_FILES['upload']['tmp_name'];
$fname = $_FILES['upload']['name'];
$transfer = move_uploaded_file($temp_name,TEMP_DIR.$fname);
$file_location = TEMP_DIR.$fname;
$inputFileType = PHPExcel_IOFactory::identify($file_location);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($file_location);
对于每行以上的代码,我产生回显时间所花费的时间
for each line of code above I echo time taken to produce the output
我的问题是,为什么
$objPHPExcel = $objReader->load($file_location);
需要17.3884秒才能加载?
其他信息:
- MS Excel 2007
- 大小384kb
- 最大列-AF
- 最大行= 184行
推荐答案
将大型文件写入光盘时phpexcel需要大量内存的相同原因...
The same reason why phpexcel needs massive amounts of memory when writing a large file to disc...
excel文档中存在大量数据,其内容,公式,条件标记,标记,引用,单元格大小等都不同...
A lot of data exists in excel documents, varying from content, formulae, conditional markup, markup, references, cell sizes, etc...
对于每个单元格,必须对其进行适当的分析,解释,并与phpexcel中的相应值相匹配.
For each cell it has to be properly analysed, interpreted, matched with corresponding values within phpexcel.
转换过程最耗时且占用大量内存.
It's the conversion proces that is the most timeconsuming and memory intensive.
您有32 x 184列数据= 5888个单元,每个表单元必须要解释= 0.002953秒,对于一个表单元来说是2.9ms.
You have 32 x 184 columns of data = 5888 cells that have to be interpreted = 0.002953 seconds per table cell, that is 2.9ms for a table cell.
考虑所有数据处理和可变事件,我发现这很快.
Considering all the data crunching and variable happenings I find that pretty fast.
如果您真的想要速度,则需要编写自己的c(++)库并将其加载到php中,那么您可以获得真正的速度提升.
If you really want speed you'll need to write your own c(++) library and load that into php, then you can get a real speed boost.
这篇关于PHPExcel加载文件超过15秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!