From eae44e779fccbd61ac03efbf38f764eba779d00b Mon Sep 17 00:00:00 2001 From: MarkPflug Date: Fri, 15 Sep 2023 10:13:01 -0700 Subject: [PATCH] Fix bug in phonetic skip logic. --- source/Sylvan.Data.Excel.Tests/CustomTests.cs | 1 + source/Sylvan.Data.Excel.Tests/TestData/Phonetic.xml | 3 +++ source/Sylvan.Data.Excel.Tests/TestData/PhoneticSST.xml | 1 + source/Sylvan.Data.Excel/Sylvan.Data.Excel.csproj | 2 +- source/Sylvan.Data.Excel/Xlsx/XlsxWorkbookReader.cs | 4 ++++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/Sylvan.Data.Excel.Tests/CustomTests.cs b/source/Sylvan.Data.Excel.Tests/CustomTests.cs index 239c58c..581dc24 100644 --- a/source/Sylvan.Data.Excel.Tests/CustomTests.cs +++ b/source/Sylvan.Data.Excel.Tests/CustomTests.cs @@ -233,5 +233,6 @@ public void Phonetic() r.Read(); Assert.Equal("NAME", r.GetString(0)); Assert.Equal("A", r.GetString(1)); + Assert.Equal("C,D", r.GetString(2)); } } diff --git a/source/Sylvan.Data.Excel.Tests/TestData/Phonetic.xml b/source/Sylvan.Data.Excel.Tests/TestData/Phonetic.xml index 4b176c1..8914a91 100644 --- a/source/Sylvan.Data.Excel.Tests/TestData/Phonetic.xml +++ b/source/Sylvan.Data.Excel.Tests/TestData/Phonetic.xml @@ -7,6 +7,9 @@ 1 + + 2 + \ No newline at end of file diff --git a/source/Sylvan.Data.Excel.Tests/TestData/PhoneticSST.xml b/source/Sylvan.Data.Excel.Tests/TestData/PhoneticSST.xml index 8e513c9..7b78ea6 100644 --- a/source/Sylvan.Data.Excel.Tests/TestData/PhoneticSST.xml +++ b/source/Sylvan.Data.Excel.Tests/TestData/PhoneticSST.xml @@ -10,4 +10,5 @@ + C,DEF \ No newline at end of file diff --git a/source/Sylvan.Data.Excel/Sylvan.Data.Excel.csproj b/source/Sylvan.Data.Excel/Sylvan.Data.Excel.csproj index 3f7e4a1..40b0a5b 100644 --- a/source/Sylvan.Data.Excel/Sylvan.Data.Excel.csproj +++ b/source/Sylvan.Data.Excel/Sylvan.Data.Excel.csproj @@ -4,7 +4,7 @@ net6.0;netstandard2.1;netstandard2.0 latest 0.4.17 - b0002 + b0003 A cross-platform .NET library for reading Excel data files. excel;xls;xlsx;xlsb;datareader enable diff --git a/source/Sylvan.Data.Excel/Xlsx/XlsxWorkbookReader.cs b/source/Sylvan.Data.Excel/Xlsx/XlsxWorkbookReader.cs index 7d51e0d..4fc5276 100644 --- a/source/Sylvan.Data.Excel/Xlsx/XlsxWorkbookReader.cs +++ b/source/Sylvan.Data.Excel/Xlsx/XlsxWorkbookReader.cs @@ -858,9 +858,13 @@ string ReadString(XmlReader reader) int c = 0; while (reader.Read() && reader.Depth > depth) { + start: if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "rPh") { SkipSubtree(reader); + // after skipping the subtree, the reader will already be positioned on the next element + // so we need to avoid calling Read again. + goto start; } else if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "t")