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.
给我你的怀抱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
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.
天蓬老师2017-06-14 10:51:59
Excel becomes slow when writing a certain amount of data. . This is normal
怪我咯2017-06-14 10:51:59
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
Import and export in batches
Optimize code and minimize database access