diff --git a/samples/xlsx/Issue888_DataWithFrame.xlsx b/samples/xlsx/Issue888_DataWithFrame.xlsx new file mode 100644 index 00000000..f65045ab Binary files /dev/null and b/samples/xlsx/Issue888_DataWithFrame.xlsx differ diff --git a/samples/xlsx/Issue888_DataWithFrame/[Content_Types].xml b/samples/xlsx/Issue888_DataWithFrame/[Content_Types].xml new file mode 100644 index 00000000..63133108 --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/[Content_Types].xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/_rels/.rels b/samples/xlsx/Issue888_DataWithFrame/_rels/.rels new file mode 100644 index 00000000..b56d8ce8 --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/_rels/.rels @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/docProps/app.xml b/samples/xlsx/Issue888_DataWithFrame/docProps/app.xml new file mode 100644 index 00000000..963f041c --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/docProps/app.xml @@ -0,0 +1,2 @@ + +Microsoft Macintosh Excel0falseWorksheets1Sheet1falsefalsefalse16.0300 \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/docProps/core.xml b/samples/xlsx/Issue888_DataWithFrame/docProps/core.xml new file mode 100644 index 00000000..4bfeedfc --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/docProps/core.xml @@ -0,0 +1,2 @@ + +Rohorzka Paul - TIN-AERohorzka Paul - TIN-AE2025-10-17T22:23:09Z2025-10-17T22:45:22Z \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/docProps/custom.xml b/samples/xlsx/Issue888_DataWithFrame/docProps/custom.xml new file mode 100644 index 00000000..c868c73d --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/docProps/custom.xml @@ -0,0 +1,2 @@ + +true2025-10-17T22:24:12ZStandardIntern157b3ee3-4ae6-4531-88f7-d8f2ad10df4f4ae664d4-52f7-48c3-9ea7-430754758029250, 3, 0, 1 \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/xl/_rels/workbook.xml.rels b/samples/xlsx/Issue888_DataWithFrame/xl/_rels/workbook.xml.rels new file mode 100644 index 00000000..65485f71 --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/xl/_rels/workbook.xml.rels @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/xl/sharedStrings.xml b/samples/xlsx/Issue888_DataWithFrame/xl/sharedStrings.xml new file mode 100644 index 00000000..f97b7610 --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/xl/sharedStrings.xml @@ -0,0 +1,2 @@ + +KeyValueKey1Value1Key2Value2 \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/xl/styles.xml b/samples/xlsx/Issue888_DataWithFrame/xl/styles.xml new file mode 100644 index 00000000..89c2d7d8 --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/xl/styles.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/xl/theme/theme1.xml b/samples/xlsx/Issue888_DataWithFrame/xl/theme/theme1.xml new file mode 100644 index 00000000..4a95cff0 --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/xl/theme/theme1.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/xl/workbook.xml b/samples/xlsx/Issue888_DataWithFrame/xl/workbook.xml new file mode 100644 index 00000000..d813aa58 --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/xl/workbook.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/samples/xlsx/Issue888_DataWithFrame/xl/worksheets/sheet1.xml b/samples/xlsx/Issue888_DataWithFrame/xl/worksheets/sheet1.xml new file mode 100644 index 00000000..b8b272b1 --- /dev/null +++ b/samples/xlsx/Issue888_DataWithFrame/xl/worksheets/sheet1.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + 0 + + + 1 + + + + + 2 + + + 3 + + + + + 4 + + + 5 + + + + + + &L_x000D_&1#&"ORF Universal SemiCond TX Regular"&7&KFFDA00 INTERN + + \ No newline at end of file diff --git a/src/MiniExcel/OpenXml/ExcelOpenXmlSheetReader.cs b/src/MiniExcel/OpenXml/ExcelOpenXmlSheetReader.cs index 1d21d581..96b74fb5 100644 --- a/src/MiniExcel/OpenXml/ExcelOpenXmlSheetReader.cs +++ b/src/MiniExcel/OpenXml/ExcelOpenXmlSheetReader.cs @@ -183,8 +183,11 @@ internal IEnumerable> InternalQueryRange(bool useHea if (rowIndex < startRowIndex) { - XmlReaderHelper.ReadFirstContent(reader); - XmlReaderHelper.SkipToNextSameLevelDom(reader); + if (XmlReaderHelper.ReadFirstContent(reader)) + { + XmlReaderHelper.SkipToNextSameLevelDom(reader); + } + continue; } if (endRowIndex.HasValue && rowIndex > endRowIndex.Value) diff --git a/tests/MiniExcelTests/MiniExcelIssueTests.cs b/tests/MiniExcelTests/MiniExcelIssueTests.cs index 1cdc95c9..49e0fe25 100644 --- a/tests/MiniExcelTests/MiniExcelIssueTests.cs +++ b/tests/MiniExcelTests/MiniExcelIssueTests.cs @@ -4737,4 +4737,29 @@ public void TestIssue880_ShouldThrowNotSerializableException() ms.SaveAs(toExport); }); } + + private record ExcelDataRow(string Key, string Value) + { + public ExcelDataRow() : this("", "") { } + } + + /// + /// https://github.com/mini-software/MiniExcel/issues/888 + /// + [Fact] + public void TestIssue888_ShouldIgnoreFrame() + { + var xlsxPath = PathHelper.GetFile("xlsx/Issue888_DataWithFrame.xlsx"); + ExcelDataRow[] dataInSheet = [ + new("Key1", "Value1"), + new("Key2", "Value2") + ]; + + using var stream = File.OpenRead(xlsxPath); + + // Act + var dataRead = stream.Query(startCell: "A2").ToArray(); + + Assert.Equal(dataInSheet, dataRead); + } } \ No newline at end of file