PHPExcel Load Files More Than 15 seconds

一曲冷凌霜 提交于 2019-12-13 03:54:03

问题


I'm using PHPExcel version 1.7.9.

Here is my PHP code :

        $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


startup Pageload in 0.0272 seconds
upload file Pageload in 0.0408 seconds
Identify File Pageload in 0.0612 seconds
Create Reader Pageload in 0.0613 seconds
Set Read Data OnlyPageload in 0.0613 seconds
File read Pageload in 17.3884 seconds

my question is, why

$objPHPExcel = $objReader->load($file_location);

take 17.3884 seconds to load?

Other information :

  • MS Excel 2007
  • Size 384kb
  • Maximum Column - AF
  • Maximum Row = 184 row

回答1:


The same reason why phpexcel needs massive amounts of memory when writing a large file to disc...

A lot of data exists in excel documents, varying from content, formulae, conditional markup, markup, references, cell sizes, etc...

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.

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.

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.



来源:https://stackoverflow.com/questions/22610906/phpexcel-load-files-more-than-15-seconds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!