Skip to content

Saving XLSX performance #4860

@cwolcott

Description

@cwolcott

Currently running version 5.4.0 and plan to upgrade to 5.7.0 tonight. I am a huge fan of this library and have been using it since 1.6.0 (Jan 2019). Started out with simple spreadsheets and getting more involved over the years.

I have had this curiosity for a long time why it seems to take so long to save xlsx spreadsheets via the library. I will say that I use a lot of the attributes to make the spreadsheet pretty and user friendly. If any one has thoughts I would be happy to try anything to speed up the process.

Attached is a spreadsheet produced by my code. I have reduced the amount of records being processed from 300,608 down to 16,192 records for this example. After saving it via PhpSpreadsheet the size of the file is 1,137,259 bytes.

RealLifeExample.xlsx

Below are some print statements to track the progress. The entire job took 1:36 to execute, of which 1:27 was spent saving the file.

2026-04-23 12:42:40 | JOB-0262 | Bob Smith | NPNPD SFP | {"libraryId":"112","libraryName":"Library 01 [Pre-frac Extracts]","assayId":"58","assayName":"MPM","extractTypes":["C","N"],"cutoff":["lte","-3",""],"worksheets":[]}
2026-04-23 12:42:40 | JOB-0262 | Source Plates prepare to retrieve
2026-04-23 12:42:41 | JOB-0262 | Source Plates retrieved - 432
2026-04-23 12:42:41 | JOB-0262 | Results prepare to retrieve
2026-04-23 12:42:41 | JOB-0262 | Results retrieved - 16192
2026-04-23 12:42:47 | JOB-0262 | TAB: SDP Calc (Begin)
2026-04-23 12:42:47 | JOB-0262 | TAB: SDP Calc (Finished)
2026-04-23 12:42:47 | JOB-0262 | TAB: Marine Analysis (Begin ZScore Calc)
2026-04-23 12:42:48 | JOB-0262 | TAB: Marine Analysis(Finished)
2026-04-23 12:42:48 | JOB-0262 | TAB: Plant Analysis (Begin ZScore Calc)
2026-04-23 12:42:49 | JOB-0262 | TAB: Plant Analysis(Finished)
2026-04-23 12:42:49 | JOB-0262 | Report saving xlsx
2026-04-23 12:44:16 | JOB-0262 | Report saved
2026-04-23 12:44:16 | JOB-0262 | Report prepare email
2026-04-23 12:44:16 | JOB-0262 | Report emailed
2026-04-23 12:44:16 | JOB-0262 | Completed - primaryScreeningNpnpdSfp.MPM.20260423.124240.xlsx

The file consists of 5 tabs, the 3rd tab is set to active so the user sees it first when the file is open.

Tab 1: Info

  • Attributes used: borders, fill, align, font
  • Other: setAutoSize, setZoomScale
  • Note: The Parameter 1 attribute can be changed to set a different cutoff that affects tabs 4 and 5 and subsequent tab 3.

Tab 2: Source Plates

  • Attributes used: borders, fill, align, font, setFormatCode
  • Other: 5 Conditional Formatting definitions, setAutoSize, setAutoFilter, setZoomScale, SetSelectedCells

Tab 3: SFP Calc

  • Attributes used: borders, fill, align, font
  • Other: setAutoSize, setZoomScale
  • Formulas: Column D and H have formulas reference the 4th and 5th tab

Tab 4: Marine Analysis

  • Attributes used: borders, fill, align, font
  • Other: 1 Conditional Formatting definition, setAutoSize, setAutoFilter, setZoomScale, SetSelectedCells
  • Formulas: Column L has formulas that reference the 1st tab

Tab 5: Plant Analysis

  • Attributes used: borders, fill, align, font
  • Other: 1 Conditional Formatting definition, setAutoSize, setAutoFilter, setZoomScale, SetSelectedCells
  • Formulas: Column L has formulas that reference the 1st tab

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions