Closed yzhoholiev closed 1 month ago
2.7.1
Create a PromptBox or ErrorBox with special characters (new line, for example).
The issue was introduced as part of the backporting of the fix for POI Bug 60370 - XSSFDataValidation, promptBox, \n ignored (no multiline).
POI Bug 60370 - XSSFDataValidation, promptBox, \n ignored (no multiline)
The bug was introduced as part of the translation of the Java implementation of the encodeUtf to C#: Original code: https://github.com/apache/poi/blob/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidation.java#L151 C# code: https://github.com/nissl-lab/npoi/blob/2.7.1-rc1/ooxml/XSSF/UserModel/XSSFDataValidation.cs#L163
encodeUtf
The Java implementation of the Integer.toHexString method does not prepend the string with the leading zeros (the spec requires it to be 4 characters long), for that reason they are manually prepended with zeros to get the required length.
Integer.toHexString
The proper implementation in C# will look like:
builder.Append("_x").Append($"{(byte) c:X4}").Append("_");
In case you want to use the HexDump helper it should be something like this:
HexDump
builder.Append("_x").Append(HexDump.ToHex((short) c)).Append("_");
bug introduced by #1354
NPOI Version
2.7.1
File Type
Reproduce Steps
Create a PromptBox or ErrorBox with special characters (new line, for example).
Issue Description
The issue was introduced as part of the backporting of the fix for
POI Bug 60370 - XSSFDataValidation, promptBox, \n ignored (no multiline)
.The bug was introduced as part of the translation of the Java implementation of the
encodeUtf
to C#: Original code: https://github.com/apache/poi/blob/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidation.java#L151 C# code: https://github.com/nissl-lab/npoi/blob/2.7.1-rc1/ooxml/XSSF/UserModel/XSSFDataValidation.cs#L163The Java implementation of the
Integer.toHexString
method does not prepend the string with the leading zeros (the spec requires it to be 4 characters long), for that reason they are manually prepended with zeros to get the required length.The proper implementation in C# will look like:
In case you want to use the
HexDump
helper it should be something like this: