From df53351856dcbb7a4e0b6102e84189e498f5c76f Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Thu, 1 Jan 2004 19:12:46 +0000 Subject: [PATCH] On HEAD, checking in testcase for 25695. But it doesnt work for reason's unknown. And its not this particular issue thats the culprit. getStringValue returns blank..:( git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353481 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hssf/data/25695.xls | Bin 0 -> 13824 bytes .../apache/poi/hssf/usermodel/TestBugs.java | 56 ++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/testcases/org/apache/poi/hssf/data/25695.xls diff --git a/src/testcases/org/apache/poi/hssf/data/25695.xls b/src/testcases/org/apache/poi/hssf/data/25695.xls new file mode 100644 index 0000000000000000000000000000000000000000..08b5035664687525f9fb5dabc7bc7e88c0ae4ad6 GIT binary patch literal 13824 zcmeHOTWnNS6kT^ZGo6;wCn5^1MLcJ+&tspx z&pvmZGw0lW?!DiBQ#W<|(_5!8D{Mp=u4F3^E#Q01-x8E-!TM}g#UNe6JXtRMhY+ZU zaUi1+oNqr{{$+|;4)QcY_#}LWG4La)7o(a7+tT|+)1&c!CTy}k^n2>VY4&M@7llV& z8ICfp<~&qQy~Pa{e{8a+EZ)GHpHYLIkG#HY9pymXo>0o<-mo}faW!KPpPSBk&~nK$Um&2G_zr?AN8?C;sQrG9ieF21I-@qY`duFlv0YcBaxe6>24{Ef`_xE|y~ zfM>gp!yiFSz;7$T?-#8PCC-DNA@ zL9U~RY=e(t+wjoP_$qOxW9oN~vs#=B6$P9%hY{w4^l-+Dk$_zz9xmZda$&?3HCf$W zT?X`Q-x2W(J=l&NT(>+wqxvi=xw>@Id=(WdN&Z$;TeKA|2>BCQ9gu+s%Yk>QEq>WJ8Oj9V4gv<8@D8x%Ojx#VBE4eL zuUdRuD{+P_lb(M&Hg!3I`^i6D9xA7@jfV7Otj1#L>1xzU%Z#3vr5=T- z7v(;y;gg!WC5U}jG*lmeI1D_ST#>Tf0JS3I*Ev z3Gy8$#(H+=9@<)qjo28f$7eQMQ*1K`jk(rY_Q3>xf~3}xO3x~PRDwp{;RL_FXH?Kr z_%K*8m1lA<_dzD>+F>|Gyl!w93LtY?hk!%CA@Ki3;0jN0B6c@ejDvQOse|wRdhxO0 z+7I81p?&#@?^lv{jKq5|+htNrb*u9bNw-uzqa^j2+WPZ)%^d^xwGevb}p?w@)rI7j*B13|Nnuc$3Z$D z*h3rZMsqj2NX9(u+ujsKS246K+ zK)<{q3Kf>PQE{R(v;od0ReHrA>a^j2si{B z0uBL(fJ49`;1F;KI0SBF1mwrdEtU(cXZaD5UZ0act?xSI>+3Z-`QP%{<-hACNBRA# zuVbob{_^vK*C*xc>pVd9mq|)pxIPi+=C=)Lj3bWCc!ud1UgXHlKP=|kBf*tv9>rsd z`97z`c)(AJW6g(v^Mrj{u@}3oAA1A#yiytR+{N^J~PU+A}`}z;*|1)3vI)1VPGA4ReH;n=7!;p=@-|Nr1Yq);9^xXCT3FK&S AmjD0& literal 0 HcmV?d00001 diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index b43d5c6c1..40282ced8 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -407,6 +407,62 @@ extends TestCase { HSSFCell cell = row.getCell((short)0); System.out.println(cell.getStringCellValue()); } + + /*Tests read and write of Unicode strings in formula results + * bug and testcase submitted by Sompop Kumnoonsate + * The file contains THAI unicode characters. + */ + public void testUnicodeStringFormulaRead() throws Exception { + + String filename = System.getProperty("HSSF.testdata.path"); + filename=filename+"/25695.xls"; + FileInputStream in = new FileInputStream(filename); + HSSFWorkbook w; + w = new HSSFWorkbook(in); + in.close(); + + HSSFCell a1 = w.getSheetAt(0).getRow(0).getCell((short) 0); + HSSFCell a2 = w.getSheetAt(0).getRow(0).getCell((short) 1); + HSSFCell b1 = w.getSheetAt(0).getRow(1).getCell((short) 0); + HSSFCell b2 = w.getSheetAt(0).getRow(1).getCell((short) 1); + HSSFCell c1 = w.getSheetAt(0).getRow(2).getCell((short) 0); + HSSFCell c2 = w.getSheetAt(0).getRow(2).getCell((short) 1); + HSSFCell d1 = w.getSheetAt(0).getRow(3).getCell((short) 0); + HSSFCell d2 = w.getSheetAt(0).getRow(3).getCell((short) 1); + + assertEquals("String Cell value", a1.getStringCellValue(), a2.getStringCellValue()); + assertEquals("String Cell value", b1.getStringCellValue(), b2.getStringCellValue()); + assertEquals("String Cell value", c1.getStringCellValue(), c2.getStringCellValue()); + assertEquals("String Cell value", d1.getStringCellValue(), d2.getStringCellValue()); + + File xls = File.createTempFile("testFormulaUnicode", ".xls"); + FileOutputStream out = new FileOutputStream(xls); + w.write(out); + out.close(); + in = new FileInputStream(xls); + + HSSFWorkbook rw = new HSSFWorkbook(in); + in.close(); + + HSSFCell ra1 = rw.getSheetAt(0).getRow(0).getCell((short) 0); + HSSFCell ra2 = rw.getSheetAt(0).getRow(0).getCell((short) 1); + HSSFCell rb1 = rw.getSheetAt(0).getRow(1).getCell((short) 0); + HSSFCell rb2 = rw.getSheetAt(0).getRow(1).getCell((short) 1); + HSSFCell rc1 = rw.getSheetAt(0).getRow(2).getCell((short) 0); + HSSFCell rc2 = rw.getSheetAt(0).getRow(2).getCell((short) 1); + HSSFCell rd1 = rw.getSheetAt(0).getRow(3).getCell((short) 0); + HSSFCell rd2 = rw.getSheetAt(0).getRow(3).getCell((short) 1); + + assertEquals("Re-Written String Cell value", a1.getStringCellValue(), ra1.getStringCellValue()); + assertEquals("Re-Written String Cell value", b1.getStringCellValue(), rb1.getStringCellValue()); + assertEquals("Re-Written String Cell value", c1.getStringCellValue(), rc1.getStringCellValue()); + assertEquals("Re-Written String Cell value", d1.getStringCellValue(), rd1.getStringCellValue()); + assertEquals("Re-Written Formula String Cell value", a1.getStringCellValue(), ra2.getStringCellValue()); + assertEquals("Re-Written Formula String Cell value", b1.getStringCellValue(), rb2.getStringCellValue()); + assertEquals("Re-Written Formula String Cell value", c1.getStringCellValue(), rc2.getStringCellValue()); + assertEquals("Re-Written Formula String Cell value", d1.getStringCellValue(), rd2.getStringCellValue()); + + } }