From 7331b7cde2e49224265843724193f0bef7b59ae2 Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Thu, 30 Oct 2003 16:46:43 +0000 Subject: [PATCH] Testcase for 24215. sync from branch git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353423 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hssf/data/24215.xls | Bin 0 -> 17408 bytes .../apache/poi/hssf/usermodel/TestBugs.java | 451 +++++++++--------- 2 files changed, 235 insertions(+), 216 deletions(-) create mode 100644 src/testcases/org/apache/poi/hssf/data/24215.xls diff --git a/src/testcases/org/apache/poi/hssf/data/24215.xls b/src/testcases/org/apache/poi/hssf/data/24215.xls new file mode 100644 index 0000000000000000000000000000000000000000..bcbbe631214b10ca75361877adbe3d89c88bea32 GIT binary patch literal 17408 zcmeHO3vg7`8UF8PlWZQqCJ_h_)|*X~@JNV>!&BJBAWdpOB&b;9tV>)>nuKVw2-u=g zD#a?T_`ouy7DVdkIvww9`c)@g06&!Vl2nttE8d-v|%-DS|JwYK-% zIrs6M|8@R*UjNy<2c9iDv~B0;SH+fQOO|{(m?t?2xQ2V(eD(^;2M76RUXRB;ASZo= zJdo$Xi_FQEPs^Uk-QSN}yyREKB?In#IE%c7+$tAKfym-Wqu&9TJu<`JziT=-tgKBOgVtt<>lCNj5wp z6_Y9|YFl-Gcc*`5Yjwht&s~9@>`SINZ&BpJ^KE36k}K%OinXTJCMyp3+~dU~l__+I z5)+7L%LJJ&5~`k{C)gCKhK+WFH2!M8Q3p_js)M0wpL@29w@C## zGbNKHc1oZ761hvJh!#SPC%^;gYRxjkCr76+W%xnwPw=O~&vQ_C_PIOdZmG|tG=!I6 zu<$jcs5|n4ByiL^e@k}2i)kEf3Ae0It$8}C z^afZ`SZ?~DOzuT{7k{N+4FjR^Gh3_7ht}~vce(rw4Lh;i7*LXk{Bj=}Z=47nElCbL z9z>0k`|(O_R5ocb(y1~abr>0_B{m#EV(hWC${4ZY00t*j8Vo^8jqJq01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cmV?d00001 diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index aaeb9b93e7..6485fa01c6 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -78,221 +78,219 @@ extends TestCase { /** Test reading AND writing a complicated workbook *Test opening resulting sheet in excel*/ - public void test15228() - throws java.io.IOException - { - String readFilename = System.getProperty("HSSF.testdata.path"); - FileInputStream in = new FileInputStream(readFilename+File.separator+"15228.xls"); - HSSFWorkbook wb = new HSSFWorkbook(in); - HSSFSheet s = wb.getSheetAt(0); - HSSFRow r = s.createRow(0); - HSSFCell c = r.createCell((short)0); - c.setCellValue(10); - File file = File.createTempFile("test15228",".xls"); - FileOutputStream out = new FileOutputStream(file); - wb.write(out); - assertTrue("No exception thrown", true); - assertTrue("File Should Exist", file.exists()); - + public void test15228() + throws java.io.IOException { + String readFilename = System.getProperty("HSSF.testdata.path"); + FileInputStream in = new FileInputStream(readFilename+File.separator+"15228.xls"); + HSSFWorkbook wb = new HSSFWorkbook(in); + HSSFSheet s = wb.getSheetAt(0); + HSSFRow r = s.createRow(0); + HSSFCell c = r.createCell((short)0); + c.setCellValue(10); + File file = File.createTempFile("test15228",".xls"); + FileOutputStream out = new FileOutputStream(file); + wb.write(out); + assertTrue("No exception thrown", true); + assertTrue("File Should Exist", file.exists()); + } - - public void test13796() - throws java.io.IOException - { - String readFilename = System.getProperty("HSSF.testdata.path"); - FileInputStream in = new FileInputStream(readFilename+File.separator+"13796.xls"); - HSSFWorkbook wb = new HSSFWorkbook(in); - HSSFSheet s = wb.getSheetAt(0); - HSSFRow r = s.createRow(0); - HSSFCell c = r.createCell((short)0); - c.setCellValue(10); - File file = File.createTempFile("test13796",".xls"); - FileOutputStream out = new FileOutputStream(file); - wb.write(out); - assertTrue("No exception thrown", true); - assertTrue("File Should Exist", file.exists()); - + + public void test13796() + throws java.io.IOException { + String readFilename = System.getProperty("HSSF.testdata.path"); + FileInputStream in = new FileInputStream(readFilename+File.separator+"13796.xls"); + HSSFWorkbook wb = new HSSFWorkbook(in); + HSSFSheet s = wb.getSheetAt(0); + HSSFRow r = s.createRow(0); + HSSFCell c = r.createCell((short)0); + c.setCellValue(10); + File file = File.createTempFile("test13796",".xls"); + FileOutputStream out = new FileOutputStream(file); + wb.write(out); + assertTrue("No exception thrown", true); + assertTrue("File Should Exist", file.exists()); + } - /**Test writing a hyperlink - * Open resulting sheet in Excel and check that A1 contains a hyperlink*/ - public void test23094() throws Exception { - File file = File.createTempFile("test23094",".xls"); - FileOutputStream out = new FileOutputStream(file); - HSSFWorkbook wb = new HSSFWorkbook(); - HSSFSheet s = wb.createSheet(); - HSSFRow r = s.createRow(0); - r.createCell((short)0).setCellFormula("HYPERLINK( \"http://jakarta.apache.org\", \"Jakarta\" )"); - assertTrue("No Exception expected",true); - wb.write(out); - out.close(); - } - + /**Test writing a hyperlink + * Open resulting sheet in Excel and check that A1 contains a hyperlink*/ + public void test23094() throws Exception { + File file = File.createTempFile("test23094",".xls"); + FileOutputStream out = new FileOutputStream(file); + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.createSheet(); + HSSFRow r = s.createRow(0); + r.createCell((short)0).setCellFormula("HYPERLINK( \"http://jakarta.apache.org\", \"Jakarta\" )"); + assertTrue("No Exception expected",true); + wb.write(out); + out.close(); + } + /* test hyperlinks * open resulting file in excel, and check that there is a link to Google **/ - public void test15353() throws Exception { - HSSFWorkbook wb = new HSSFWorkbook(); - HSSFSheet sheet = wb.createSheet("My sheet"); + public void test15353() throws Exception { + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet("My sheet"); + + HSSFRow row = sheet.createRow( (short) 0 ); + HSSFCell cell = row.createCell( (short) 0 ); + cell.setCellFormula("HYPERLINK(\"http://google.com\",\"Google\")"); + + // Write out the workbook + File f = File.createTempFile("test15353",".xls"); + FileOutputStream fileOut = new FileOutputStream(f); + wb.write(fileOut); + fileOut.close(); + } + + /** test reading of a formula with a name and a cell ref in one + **/ + public void test14460() throws Exception { + String filename = System.getProperty("HSSF.testdata.path"); + filename=filename+"/14460.xls"; + FileInputStream in = new FileInputStream(filename); + HSSFWorkbook wb = new HSSFWorkbook(in); + HSSFSheet sheet = wb.getSheetAt(0); + assertTrue("No exception throws", true); + } + + public void test14330() throws Exception { + String filedir = System.getProperty("HSSF.testdata.path"); + String filename=filedir+"/14330-1.xls"; + FileInputStream in = new FileInputStream(filename); + HSSFWorkbook wb = new HSSFWorkbook(in); + HSSFSheet sheet = wb.getSheetAt(0); + + filename=filedir+"/14330-2.xls"; + in = new FileInputStream(filename); + wb = new HSSFWorkbook(in); + sheet = wb.getSheetAt(0); + assertTrue("No exception throws", true); + } + + /** test rewriting a file with large number of unique strings + *open resulting file in Excel to check results!*/ + public void test15375() { + + try { + String filename = System.getProperty("HSSF.testdata.path"); + filename=filename+"/15375.xls"; + FileInputStream in = new FileInputStream(filename); + HSSFWorkbook wb = new HSSFWorkbook(in); + HSSFSheet sheet = wb.getSheetAt(0); - HSSFRow row = sheet.createRow( (short) 0 ); - HSSFCell cell = row.createCell( (short) 0 ); - cell.setCellFormula("HYPERLINK(\"http://google.com\",\"Google\")"); + HSSFRow row = sheet.getRow(5); + HSSFCell cell = row.getCell((short)3); + if (cell == null) + cell = row.createCell((short)3); - // Write out the workbook - File f = File.createTempFile("test15353",".xls"); + // Write test + cell.setCellType(HSSFCell.CELL_TYPE_STRING); + cell.setCellValue("a test"); + + // change existing numeric cell value + + HSSFRow oRow = sheet.getRow(14); + HSSFCell oCell = oRow.getCell((short)4); + oCell.setCellValue(75); + oCell = oRow.getCell((short)5); + oCell.setCellValue("0.3"); + + // Write the output to a file + File f = File.createTempFile("test15375",".xls"); FileOutputStream fileOut = new FileOutputStream(f); wb.write(fileOut); fileOut.close(); } - - /** test reading of a formula with a name and a cell ref in one - **/ - public void test14460() throws Exception { - String filename = System.getProperty("HSSF.testdata.path"); - filename=filename+"/14460.xls"; - FileInputStream in = new FileInputStream(filename); - HSSFWorkbook wb = new HSSFWorkbook(in); - HSSFSheet sheet = wb.getSheetAt(0); - assertTrue("No exception throws", true); - } - - public void test14330() throws Exception { - String filedir = System.getProperty("HSSF.testdata.path"); - String filename=filedir+"/14330-1.xls"; - FileInputStream in = new FileInputStream(filename); - HSSFWorkbook wb = new HSSFWorkbook(in); - HSSFSheet sheet = wb.getSheetAt(0); - - filename=filedir+"/14330-2.xls"; - in = new FileInputStream(filename); - wb = new HSSFWorkbook(in); - sheet = wb.getSheetAt(0); - assertTrue("No exception throws", true); - } + catch (java.io.FileNotFoundException ex) { + ex.printStackTrace(); + } + catch (java.io.IOException ex) { + ex.printStackTrace(); + } + + } + + /** test writing a file with large number of unique strings + *open resulting file in Excel to check results!*/ + + public void test15375_2() throws Exception{ + + + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet(); + + String tmp1 = null; + String tmp2 = null; + String tmp3 = null; + + for (int i = 0; i < 6000; i++) { + tmp1 = "Test1" + i; + tmp2 = "Test2" + i; + tmp3 = "Test3" + i; + + HSSFRow row = sheet.createRow((short)i); + + HSSFCell cell = row.createCell((short)0); + cell.setCellValue(tmp1); + cell = row.createCell((short)1); + cell.setCellValue(tmp2); + cell = row.createCell((short)2); + cell.setCellValue(tmp3); + } + File f = File.createTempFile("test15375-2",".xls"); + FileOutputStream fileOut = new FileOutputStream(f); + wb.write(fileOut); + fileOut.close(); + } + /** another test for the number of unique strings issue + *test opening the resulting file in Excel*/ + public void test22568() { + int r=2000;int c=3; + + HSSFWorkbook wb = new HSSFWorkbook() ; + HSSFSheet sheet = wb.createSheet("ExcelTest") ; + + int col_cnt=0, rw_cnt=0 ; + + col_cnt = c; + rw_cnt = r; + + HSSFRow rw = null ; + HSSFCell cell =null; + rw = sheet.createRow((short)0) ; + //Header row + for(short j=0; j