D
D
Denis2019-02-11 10:29:11
PHP
Denis, 2019-02-11 10:29:11

How to export big data to excel?

Good afternoon. Maybe someone came across with exporting a large amount of data (more than 100k) to excel (xlsx format). Can you please tell me how to implement something like this? The data is taken from a MySQL database. The system itself that initiates the export is written in php.

Answer the question

In order to leave comments, you need to log in

8 answer(s)
B
Barmunk, 2019-02-11
@Barmunk

There is a special package for large volume export, you can try it.
https://github.com/box/spout

Spout is a PHP library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way. Contrary to other file readers or writers, it is capable of processing very large files while keeping the memory usage really low (less than 3MB).

A
Anton Mashletov, 2019-02-11
@mashletov

Do not listen to advisers with PHPExcel. It already at 5-10k lines will start consuming 100+ MB of RAM.
People's candidate: box/spout . Writes to a file on the fly. Minus: almost complete lack of formatting. Doesn't know how to do neither column width nor edge alignment... Only font/borders.

K
konst74, 2019-02-11
@konst74

Purely from experience in Excel, with volumes of hundreds of thousands of lines and more or less complex calculations, it starts to get very stupid and recalculate sheets for 30 seconds. I would have thought a hundred times how to use it later) It can merge at least somehow aggregated data

P
Pychev Anatoly, 2019-02-11
@pton

Or use the PHPExcel library to generate an excel file

D
Denis, 2019-02-11
@denis6064

Or maybe there is an easier option? like ETL (it is currently used, but such a number of lines cannot be written to a file)

E
Eugene Kuznetsov, 2019-02-22
@KEugene

Just in case, I'll add that the modern version of Excel can take data directly from MySQL just fine. Maybe, well, his, "intermediate links"? ...

D
Dmitry Shooters, 2019-02-22
@sni10

https://github.com/sni10/importHelper
You can connect any Lib to work with the body of the file, even box/spout , even PHPExcel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question