PHPExcel加载文件超过15秒 [英] PHPExcel Load Files More Than 15 seconds

查看:142
本文介绍了PHPExcel加载文件超过15秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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


启动页面加载时间为0.0272秒
在0.0408秒内上传文件Pageload
在0.0612秒内确定文件页面加载
在0.0613秒内创建阅读器页面加载
在0.0613秒内将Read Only OnlyPageload设置为
文件在17.3884秒内读取了页面加载


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

我的问题是,为什么

$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秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆