D
D
Dr Zhmurge2022-02-04 13:44:49
PHP
Dr Zhmurge, 2022-02-04 13:44:49

What is the best way to form xlsx in php for 10+ million cells?

Phpsreadsheet does a poor job. 4 GB of RAM is already running out of 4 million cells. And the unloading process takes about 30 minutes. Can anyone advise faster libraries or methods?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shamanov, 2022-02-04
@SilenceOfWinter

xlsx is a zip archive with xml files, you can create it manually, make a file template so that you do not generate from scratch and it is easier to insert content. but such a volume of data will slow down in any case, even if you convert it to CSV

S
Sergey c0re, 2022-02-04
@erge

To make it faster, work with xl/worksheets/sheet?.xml files (inside the zip archive - xlsx file) directly! either as with XML, or as with text search / replace (through regular expressions for example), although ... if this is a clean file from scratch, then it is easier and faster to generate these files from scratch as text, in this file there is data in the sheetData section, see .example:

<sheetData>
    <row r="1">
      <c r="A1" t="str">
        <v>Иванов</v>
      </c>
      <c r="B1" t="str">
        <v>Петров</v>
      </c>
      <c r="С1" t="str">
        <v>Сидоров</v>
      </c>
...
    </row>
  </sheetData>

PS: Yes, save any exelnik in xlsx, rename it to zip and see, you will understand.
Either switch to a bundle ... for example, to Go + the Excelize package and either make a microservice on it and work accordingly, or a cmdline binary and call it from PHP accordingly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question