diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 7b1b3bbfd..a87636e9f 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 51143 - NameCommentRecord correction for writing non ASCII strings 51112 - Correct XWPFTable tracking of new rows 51113 - Correct XWPFParagraph tracking of inserted runs 51111 - Correct XWPFParagraph tracking of new runs diff --git a/src/java/org/apache/poi/hssf/record/NameCommentRecord.java b/src/java/org/apache/poi/hssf/record/NameCommentRecord.java index 36d6132d0..ed33c2d1f 100644 --- a/src/java/org/apache/poi/hssf/record/NameCommentRecord.java +++ b/src/java/org/apache/poi/hssf/record/NameCommentRecord.java @@ -63,9 +63,9 @@ public final class NameCommentRecord extends StandardRecord { out.writeShort(field_5_comment_length); out.writeByte(0); - out.write(field_6_name_text.getBytes()); + StringUtil.putCompressedUnicode(field_6_name_text, out); out.writeByte(0); - out.write(field_7_comment_text.getBytes()); + StringUtil.putCompressedUnicode(field_7_comment_text, out); } @Override diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 2dfe1a01a..8341f465a 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -2112,4 +2112,15 @@ if(1==2) { c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1, )"); assertEquals("v A1", eval.evaluate(c).getStringValue()); } + + /** + * Mixture of Ascii and Unicode strings in a + * NameComment record + */ + public void test51143() throws Exception { + HSSFWorkbook wb = openSample("51143.xls"); + assertEquals(1, wb.getNumberOfSheets()); + wb = writeOutAndReadBack(wb); + assertEquals(1, wb.getNumberOfSheets()); + } } diff --git a/test-data/spreadsheet/51143.xls b/test-data/spreadsheet/51143.xls new file mode 100644 index 000000000..a89a10980 Binary files /dev/null and b/test-data/spreadsheet/51143.xls differ