Skip to content

Fix lazy loading race conditions and missing EnsureLoaded calls in XSSFSheet#1678

Draft
Copilot wants to merge 9 commits intomasterfrom
copilot/load-sheet-on-xssf-sheet-use
Draft

Fix lazy loading race conditions and missing EnsureLoaded calls in XSSFSheet#1678
Copilot wants to merge 9 commits intomasterfrom
copilot/load-sheet-on-xssf-sheet-use

Conversation

Copy link

Copilot AI commented Feb 3, 2026

Recent lazy loading implementation in XSSFSheet introduced three categories of failures where methods accessed uninitialized fields before calling EnsureLoaded().

Changes

  • Stack overflow fix: Set isLoaded = true before calling Read() in OnDocumentRead() instead of after. XSSFRow constructor accesses LastRowNum during initialization, which calls EnsureLoaded() again, causing infinite recursion when flag is set post-load.

  • SetRepeatingRowsAndColumns: Added EnsureLoaded() call. Method accesses worksheet.IsSetPageSetup() and worksheet.IsSetPageMargins() which are null until sheet loads.

  • GetTables: Added EnsureLoaded() call. Method accesses tables dictionary which is initialized in InitRows() during load.

Test Results

  • TestSetRepeatingRowsAndColumns: 4/4 passing (was 0/4)
  • TestXSSFTable: 20/20 passing (was 3/20)
  • XSSFSheet suite: 209/258 passing (improved from 205/258)

All fixes follow the existing pattern where methods accessing sheet state initialized during load must call EnsureLoaded() first.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits February 3, 2026 15:32
…cess worksheet field in XSSFSheet.cs

Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot AI changed the title [WIP] Load sheet only when XSSFSheet object is used Implement lazy loading for XSSFSheet Feb 3, 2026
Copilot AI requested a review from tonyqus February 3, 2026 15:55
Copilot stopped work on behalf of tonyqus due to an error February 3, 2026 16:18
Copilot stopped work on behalf of tonyqus due to an error February 3, 2026 16:18
Copilot stopped work on behalf of tonyqus due to an error February 3, 2026 16:19
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot AI changed the title Implement lazy loading for XSSFSheet Fix stack overflow in lazy sheet loading from recursive EnsureLoaded Feb 3, 2026
…tingRowsAndColumns

Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot AI changed the title Fix stack overflow in lazy sheet loading from recursive EnsureLoaded Add missing EnsureLoaded call to SetRepeatingRowsAndColumns Feb 3, 2026
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot AI changed the title Add missing EnsureLoaded call to SetRepeatingRowsAndColumns Fix lazy loading race conditions and missing EnsureLoaded calls in XSSFSheet Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments