Skip to content

Expanded data reader capabilities#971

Merged
michelebastione merged 8 commits into
mini-software:masterfrom
michelebastione:datareader-multiple-resultsets
Jun 6, 2026
Merged

Expanded data reader capabilities#971
michelebastione merged 8 commits into
mini-software:masterfrom
michelebastione:datareader-multiple-resultsets

Conversation

@michelebastione

Copy link
Copy Markdown
Collaborator

New IDataReader implementations

The MiniExcelDataReader class has been converted into the abstract class MiniExcelDataReaderBase and two implementations have been derived from it: OpenXmlDataReader and CsvDataReader. This differentation was made so that OpenXmlDataReader could support reading all sheets of a workbook through the NextResult and NextResultAsync methods, which is now an available feature and thus this PR closes #485. Incidentally, CsvDataReader instantiation has been simplified as the parameters sheetName and startCell are not required for it anymore.

Other changes

  • Changed main MiniExcel class' namespace from MiniExcelLib.Core to MiniExcelLib, as it makes more sense for the API entry point to belong to the root namespace
  • Changed sheetName parameter in methods RetrieveComments and QueryTable to default to null (with no change in behaviour) for consistency with the other OpenXmlImporter's methods
  • Other minor implementation changes throughout the codebase

…celLib

It makes more sense for consumers of the library for the main `MiniExcel` class to find it under the simpler mainspace
Added `AutoDeletingPath` where missing, removed unused pragmas and moved `TestDto` class to models file
The `sheetName` parameter now defaults to null and the first worksheet of the Excel workbook will be selected even if its name is not "Sheet1"
Changed `IMiniExcelReader` interface to inherit from `IAsyncDisposable`, implemented pattern in `OpenXmlReader` and `CsvReader`.
Also addressed `ZipArchive` not being disposed correctly at the end of a session and updated the tests that were affected.
Separated `MiniExcelDataReader` into `CsvDataReader` and `OpenXmlDataReader` implementations, making them inherit the new `MiniExcelDataReaderBase` abstract class.
After these changes `OpenXmlDataReader` now supports reading all sheets of a workbook through the `NextResult` and `NextResultAsync` methods.
Updated CsvImporter and OpenXmlImporter to return the new reader types and to create/dispose streams/readers safely, added unit tests and CSV test data, and updated README examples.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the data reader implementation by introducing a common base class MiniExcelDataReaderBase and splitting it into concrete CsvDataReader and OpenXmlDataReader classes. It also adds support for reading multiple worksheets sequentially via NextResult and NextResultAsync in OpenXmlDataReader, and updates stream disposal behavior across various APIs. The code review highlights several critical issues: a bug in OpenXmlDataReader.Create where the stream is disposed regardless of the leaveOpen flag, multiple potential NullReferenceExceptions due to missing null checks on Source, AsyncSource, and SharedStrings during disposal, and a potential data loss issue in CsvReader caused by creating and disposing a temporary StreamReader in the constructor.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/MiniExcel.OpenXml/OpenXmlDataReader.cs Outdated
Comment thread src/MiniExcel.Core/MiniExcelDataReaderBase.cs Outdated
Comment thread src/MiniExcel.Core/MiniExcelDataReaderBase.cs Outdated
Comment thread src/MiniExcel.Core/MiniExcelDataReaderBase.cs Outdated
Comment thread src/MiniExcel.OpenXml/Reader/OpenXmlReader.cs
Comment thread src/MiniExcel.Csv/CsvReader.cs
@michelebastione michelebastione force-pushed the datareader-multiple-resultsets branch from 1ea6c51 to bf8f6c3 Compare June 6, 2026 14:11
@michelebastione michelebastione merged commit d5ca690 into mini-software:master Jun 6, 2026
3 checks passed
@michelebastione michelebastione deleted the datareader-multiple-resultsets branch June 6, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for querying all sheets in a workbook and returning them as result sets

1 participant