Expanded data reader capabilities#971
Conversation
…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.
There was a problem hiding this comment.
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.
…ixed tests and sample data
1ea6c51 to
bf8f6c3
Compare
New
IDataReaderimplementationsThe
MiniExcelDataReaderclass has been converted into the abstract classMiniExcelDataReaderBaseand two implementations have been derived from it:OpenXmlDataReaderandCsvDataReader. This differentation was made so thatOpenXmlDataReadercould support reading all sheets of a workbook through theNextResultandNextResultAsyncmethods, which is now an available feature and thus this PR closes #485. Incidentally,CsvDataReaderinstantiation has been simplified as the parameterssheetNameandstartCellare not required for it anymore.Other changes
MiniExcelclass' namespace fromMiniExcelLib.CoretoMiniExcelLib, as it makes more sense for the API entry point to belong to the root namespacesheetNameparameter in methodsRetrieveCommentsandQueryTableto default to null (with no change in behaviour) for consistency with the otherOpenXmlImporter's methods