Skip to content

Commit

Permalink
Fix a bug where headers on subsequent sheets might not load properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkPflug committed Nov 29, 2023
1 parent e234cd4 commit 953bdb6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Sylvan.Data.Excel Release Notes

_0.4.19_
- Fix a bug where headers might not be read properly on sheets after the first sheet.

_0.4.18_
- Fix a bug where column filters were applied to one too many columns when writing .xlsb files.
- Fix a bug where data would be skipped when headers were disabled and a worksheet started with blank line(s).
Expand Down
18 changes: 18 additions & 0 deletions source/Sylvan.Data.Excel.Tests/ExcelDataReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,24 @@ public void Date1900()
Assert.Equal(new DateTime(2025, 1, 21), edr.GetDateTime(0));
}

[Fact]
public void MultiSheetHeaders()
{
var file = GetFile("MultiSheet");
var edr = ExcelDataReader.Create(file);
var s = edr.GetColumnSchema();
var c = s.Count;
Assert.Equal(1, c);
Assert.Equal("a", s[0].ColumnName);
while (edr.Read()) ;
Assert.True(edr.NextResult());
s = edr.GetColumnSchema();
c = s.Count;
Assert.Equal(1, c);
Assert.Equal("d", s[0].ColumnName);
Assert.False(edr.NextResult());
}

#if ASYNC

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion source/Sylvan.Data.Excel/Sylvan.Data.Excel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<VersionPrefix>0.4.18</VersionPrefix>
<VersionPrefix>0.4.19</VersionPrefix>
<Description>A cross-platform .NET library for reading Excel data files.</Description>
<PackageTags>excel;xls;xlsx;xlsb;datareader</PackageTags>
<Nullable>enable</Nullable>
Expand Down
4 changes: 2 additions & 2 deletions source/Sylvan.Data.Excel/Xlsx/XlsxWorkbookReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private protected override bool OpenWorksheet(int sheetIdx)
};

this.reader = XmlReader.Create(tr, settings);

this.rowIndex = 0;
// worksheet
while (reader.Read())
{
Expand Down Expand Up @@ -262,7 +262,7 @@ public override bool NextResult()
{
return false;
}

return OpenWorksheet(sheetIdx);
}

Expand Down

0 comments on commit 953bdb6

Please sign in to comment.