Cookbook

In-memory XLSX spreadsheets

phpxlsx Premium licenses include support for in-memory spreadsheets. Thanks to this functionality it is possible to work without files in the fs. Instead, you can use in memory objects or from other sources like databases, in-memory data structures, redis… This also enables better performance and flexibility of use.

XlsxStructure is the class that serves as an in-memory XLSX in phpxlsx. An object of that class can be generated on the fly with CreateXlsx and the static attribute $returnXlsxStructure:

Or from an existing file, using the XlsxStructure class:

XlsxStructure can be easily serialized for later reuse. For example, as a template to generate new spreadsheets:

The classes and methods that support in-memory XLSX are the following:

XlsxStructure objects should not be confused with the phpxlsx stream mode. The latter generates and returns automatically the XLSX file, but it doesn't allow storing it unless its output is captured. That's why it is useful for specific purporses as generating and downloading XLSX without being neccesary its later reuse.

Related information