Skip to content

Query skips empty rows represented as self-closing tags. #672

Description

@aulickiDnv

Excel Type

  • [X ] XLSX
  • [ X] XLSM
  • CSV
  • OTHER

Upload Excel File

EmptySelfClosingRow.xlsx

MiniExcel Version

1.34.2

Description

Empty rows in excel can be represented as self closing tags (e.g. ) those rows are skipped by Query.

Based on attached test case a test like this will not pass:

        [Fact]
        public void CenterEmptyRowsQueryTest2()
        {
            var path = @"../../../../../samples/xlsx/EmptySelfClosingRow.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);
            }
        }

As row 3 is specified like this in inner XML:
<row r="3" spans="1:3" s="1" customFormat="1" x14ac:dyDescent="0.25"/>

In ExcelOpenXmlSheetReader.cs line 279 adding a return before continue solves this issue:

       if (!XmlReaderHelper.ReadFirstContent(reader))
       {
           // missing empty return for self closing rows
           // yield return GetCell(useHeaderRow, maxColumnIndex, headRows, startColumnIndex); 
           continue;
       }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions