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
10 changes: 10 additions & 0 deletions src/ExcelDataReader.Tests/ExcelOpenXmlReaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ public void CellFormat49()
Assert.That(result.Tables[0].Rows[0].ItemArray, Is.EqualTo(new object[] { "2010-05-05", "1.1", 2.2000000000000002D, 123.0D, "2,2" }));
}

[Test]
public void FullWidthSpace()
{
using var reader = OpenReader("Test_FullWidthSpace");
var dataSet = reader.AsDataSet();
Assert.That(dataSet.Tables[0].Rows[0].ItemArray[0], Is.EqualTo("\u3000\u3000text\u3000\u3000"));
Assert.That(dataSet.Tables[0].Rows[1].ItemArray[0], Is.EqualTo("text\u3000"));
Assert.That(dataSet.Tables[0].Rows[2].ItemArray[0], Is.EqualTo("\u3000text"));
}

[Test]
public void GitIssue97()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ internal static class StringHelper
private const string ElementT = "t";
private const string ElementR = "r";

// https://www.w3.org/TR/REC-xml#NT-S
private static readonly char[] WhitespaceChars = [' ', '\t', '\n', '\r'];

public static string ReadStringItem(XmlReader reader, string nsSpreadsheetMl)
{
if (!XmlReaderHelper.ReadFirstContent(reader))
Expand Down Expand Up @@ -63,6 +66,6 @@ private static string ReadElementContent(XmlReader reader)
if (reader.GetAttribute("xml:space") == "preserve")
return reader.ReadElementContentAsString();
else
return reader.ReadElementContentAsString().Trim();
return reader.ReadElementContentAsString().Trim(WhitespaceChars);
}
}
Binary file added src/TestData/Test_FullWidthSpace.xlsx
Binary file not shown.