Sheet Lazy Loading Implementation#1741
Merged
tonyqus merged 14 commits intonissl-lab:masterfrom Mar 21, 2026
Merged
Conversation
- Add _worksheetLoaded, _loadLock, and _parseCount fields - OnDocumentRead() defers parsing; lazy-loads on first access - OnDocumentCreate() marks sheet as loaded immediately - Add EnsureWorksheetLoaded() with double-checked locking - Override PrepareForCommit()/Commit() to skip unloaded sheets - Add EnsureWorksheetLoaded() call to all public/internal methods and property getters/setters that access worksheet data Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Set _worksheetLoaded = true before calling Read() to prevent infinite recursion when Read() triggers callbacks (XSSFRow constructor calls OnReadCell(), LastRowNum, PhysicalNumberOfRows) that themselves call EnsureWorksheetLoaded(). Reset _worksheetLoaded = false on exception to allow retry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests verify that: - Opening a workbook does not parse sheet XML - GetSheetAt/GetSheet alone do not trigger parsing - First content access triggers parse exactly once - Subsequent accesses do not re-parse (_parseCount stays at 1) - Newly created in-memory sheets work without parsing - Data correctness after lazy load - Multiple sheets are independently lazy-loaded Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
…f-sheets Implement lazy loading for XSSFSheet — defer sheet.xml parsing to first content access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BenchmarkDotNet v0.13.12, Windows 11 (10.0.26200.8037)
12th Gen Intel Core i5-12400, 1 CPU, 12 logical and 6 physical cores
.NET SDK 10.0.201
[Host] : .NET 8.0.25 (8.0.2526.11203), X64 RyuJIT AVX2
ShortRun : .NET 8.0.25 (8.0.2526.11203), X64 RyuJIT AVX2
Job=ShortRun IterationCount=3 LaunchCount=1
WarmupCount=3