Yield empty self-closing row tags as empty row during query. (#673)

This commit is contained in:
aulickiDnv 2024-09-28 12:24:12 +02:00 committed by GitHub
parent 831c814788
commit 436aaa80c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 2 deletions

Binary file not shown.

View File

@ -277,7 +277,11 @@ namespace MiniExcelLibs.OpenXml
// row -> c // row -> c
if (!XmlReaderHelper.ReadFirstContent(reader)) 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; continue;
}
// startcell pass rows // startcell pass rows
if (rowIndex < startRowIndex) if (rowIndex < startRowIndex)

View File

@ -252,6 +252,27 @@ namespace MiniExcelLibs.Tests
} }
} }
[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()] [Fact()]
public void TestDynamicQueryBasic_WithoutHead() public void TestDynamicQueryBasic_WithoutHead()
{ {