How to improve the efficiency of php excel export
欧阳克
欧阳克 2017-06-14 10:49:59
0
4
1240

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.

欧阳克
欧阳克

温故而知新,可以为师矣。 博客:www.ouyangke.com

reply all(4)
给我你的怀抱

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

Ty80

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.

Peter_Zhu

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

刘奇
  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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!