Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added samples/xlsx/TestEmptySelfClosingRow.xlsx
Binary file not shown.
4 changes: 4 additions & 0 deletions src/MiniExcel/OpenXml/ExcelOpenXmlSheetReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,11 @@ public IEnumerable<IDictionary<string, object>> Query(bool useHeaderRow, string

// row -> c
if (!XmlReaderHelper.ReadFirstContent(reader))
{
//Fill in case of self closed empty row tag eg. <row r="1"/>
yield return GetCell(useHeaderRow, maxColumnIndex, headRows, startColumnIndex);
continue;
}

// startcell pass rows
if (rowIndex < startRowIndex)
Expand Down
25 changes: 23 additions & 2 deletions tests/MiniExcelTests/MiniExcelOpenXmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void QueryRangeToIDictionary()
Assert.Equal(2d, rows[1]["B"]);
Assert.Equal(null!, rows[2]["A"]);
}

[Fact()]
public void CenterEmptyRowsQueryTest()
{
Expand All @@ -201,7 +201,7 @@ public void CenterEmptyRowsQueryTest()

Assert.Equal(null, rows[2].A);
Assert.Equal(2, rows[2].B);
Assert.Equal(null, rows[2].C);
Assert.Equal(null, rows[2].C);
Assert.Equal(4, rows[2].D);

Assert.Equal(null, rows[3].A);
Expand Down Expand Up @@ -252,6 +252,27 @@ public void CenterEmptyRowsQueryTest()
}
}

[Fact]
public void TestEmptyRowsQuerySelfClosingTag()
{
var path = @"../../../../../samples/xlsx/TestEmptySelfClosingRow.xlsx";
using (var stream = File.OpenRead(path))
{
var rows = stream.Query().ToList();

Assert.Equal(null, rows[0].A);
Assert.Equal(1, rows[1].A);
Assert.Equal(null, rows[2].A);
Assert.Equal(2, rows[3].A);
Assert.Equal(null, rows[4].A);
Assert.Equal(null, rows[5].A);
Assert.Equal(null, rows[6].A);
Assert.Equal(null, rows[7].A);
Assert.Equal(null, rows[8].A);
Assert.Equal(1, rows[9].A);
}
}

[Fact()]
public void TestDynamicQueryBasic_WithoutHead()
{
Expand Down