search

Home  >  Q&A  >  body text

How to improve the efficiency of php excel export

How to improve the efficiency of phpexcel export (note: cvs format can be ignored, this export has cell operation operations)

What I am thinking of now is:
Optimizing SQL now has an interface for data details. Now it is to get the ID array of the data to loop through the project details interface to extract the required fields

I haven’t thought of any other good methods at the moment, so please give me some advice.

欧阳克欧阳克2721 days ago1254

reply all(4)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-06-14 10:51:59

    The performance of phpExcel is very poor and takes up memory. This will generally limit the number of exported rows. If you don’t think too much about style, you can use the t method to export excel,

    Give me an example

    <?php
    header("Content-type:application/vnd.ms-excel");
    header("Content-Disposition:attachment;filename=test_data.xls");
    //输出内容如下: 
    echo   "姓名"."\t"; 
    echo   "年龄"."\t"; 
    echo   "学历"."\t"; 
    echo   "\n"; 
    echo   "张三"."\t"; 
    echo   "25"."\t"; 
    echo   "本科"."\t"; 
    ?>

    Our company currently uses t to export excel data, and its performance is better than phpExcel. The questioner can test the performance ratio

    reply
    0
  • PHP中文网

    PHP中文网2017-06-14 10:51:59

    1. It’s easy to optimize without relying on phpexcel. In fact, you don’t need many function methods. And it also needs to load
    2.sql query is also an optimization. I won’t talk about this without seeing the code.
    3. When you extract too much data from sql, it actually takes up a lot of php memory, so it is recommended to clear the data immediately after writing it to excel.

    reply
    0
  • 天蓬老师

    天蓬老师2017-06-14 10:51:59

    Excel becomes slow when writing a certain amount of data. . This is normal

    reply
    0
  • 怪我咯

    怪我咯2017-06-14 10:51:59

    1. Use the queue to asynchronously execute the import and export of PHPExcel, especially when executing tens of thousands, hundreds of thousands or even millions of data

    2. Import and export in batches

    3. Optimize code and minimize database access

    reply
    0
  • Cancelreply