Posts

Showing posts from July, 2021

Redis as cache for excel generation using Phpspreadsheet

Image
  Redis as cache for excel generation using Phpspreadsheet.   Generating excel files with Phpspreadsheet library is a common task in many projects. That library holds by default in memory the cells representation. In some cases, when the file to be generated is really BIG that default configuration provoke PHP memory limitation. Problem Memory limitation issues when generating really BIG excel files. The library by default loads the cells representation in memory and at some point it is susceptible to PHP's memory limitations.   F atal error allowed memory size of " M " bytes exhausted tried to allocate "N" bytes in "K" on line "L"     Solution It's created a cache implementation using Redis to be used by Phpspreadsheet for storing the excel cell representation.    How to use:   Before the initialization of any Spreadsheet instance it’s needed to indicate Phpspreadsheet that th