📄 testbugs.java
字号:
in.close(); for(int i = 1; i < 400; i++) { HSSFRow row = sheet.getRow(i); if(row != null) { HSSFCell cell = row.getCell((short)0); } } assertTrue("No Exceptions while reading file", true); } /** * Bug 29675: POI 2.5 final corrupts output when starting workbook has a graphic */ public void test29675() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "29675.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); assertTrue("No Exceptions while reading file", true); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Bug 29942: Importing Excel files that have been created by Open Office on Linux */ public void test29942() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "29942.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); HSSFSheet sheet = wb.getSheetAt(0); int count = 0; for (int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++) { HSSFRow row = sheet.getRow(i); if (row != null) { HSSFCell cell = row .getCell((short)0); assertEquals(HSSFCell.CELL_TYPE_STRING, cell.getCellType()); count++; } } assertEquals(85, count); //should read 85 rows assertTrue("No Exceptions while reading file", true); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Bug 29982: Unable to read spreadsheet when dropdown list cell is selected - * Unable to construct record instance */ public void test29982() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "29982.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); assertTrue("No Exceptions while reading file", true); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Bug 30540: HSSFSheet.setRowBreak throws NullPointerException */ public void test30540() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "30540.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); HSSFSheet s = wb.getSheetAt(0); s.setRowBreak(1); assertTrue("No Exceptions while reading file", true); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Bug 31749: {Need help urgently}[This is critical] workbook.write() corrupts the file......? */ public void test31749() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "31749.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); assertTrue("No Exceptions while reading file", true); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Bug 31979: {urgent help needed .....}poi library does not support form objects properly. */ public void test31979() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "31979.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); assertTrue("No Exceptions while reading file", true); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); //wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Bug 35564: HSSFCell.java: NullPtrExc in isGridsPrinted() and getProtect() * when HSSFWorkbook is created from file */ public void test35564() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "35564.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); HSSFSheet sheet = wb.getSheetAt( 0 ); assertEquals(false, sheet.isGridsPrinted()); assertEquals(false, sheet.getProtect()); assertTrue("No Exceptions while reading file", true); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Bug 35565: HSSFCell.java: NullPtrExc in getColumnBreaks() when HSSFWorkbook is created from file */ public void test35565() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "35565.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); HSSFSheet sheet = wb.getSheetAt( 0 ); assertNotNull(sheet); assertTrue("No Exceptions while reading file", true); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Bug 37376: Cannot open the saved Excel file if checkbox controls exceed certain limit */ public void test37376() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "37376.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); assertTrue("No Exceptions while reading file", true); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Bug 40285: CellIterator Skips First Column */ public void test40285() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "40285.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); HSSFSheet sheet = wb.getSheetAt( 0 ); int rownum = 0; for (Iterator it = sheet.rowIterator(); it.hasNext(); rownum++) { HSSFRow row = (HSSFRow)it.next(); assertEquals(rownum, row.getRowNum()); int cellNum = 0; for (Iterator it2 = row.cellIterator(); it2.hasNext(); cellNum++) { HSSFCell cell = (HSSFCell)it2.next(); assertEquals(cellNum, cell.getCellNum()); } } } /** * Bug 40296: HSSFCell.setCellFormula throws * ClassCastException if cell is created using HSSFRow.createCell(short column, int type) */ public void test40296() throws Exception { HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook workBook = new HSSFWorkbook(); HSSFSheet workSheet = workBook.createSheet("Sheet1"); HSSFCell cell; HSSFRow row; row = workSheet.createRow(0); cell = row.createCell((short)0, HSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(1.0); cell = row.createCell((short)1, HSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(2.0); cell = row.createCell((short)2, HSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("SUM(A1:B1)"); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } /** * Test bug 38266: NPE when adding a row break * * User's diagnosis: * 1. Manually (i.e., not using POI) create an Excel Workbook, making sure it * contains a sheet that doesn't have any row breaks * 2. Using POI, create a new HSSFWorkbook from the template in step #1 * 3. Try adding a row break (via sheet.setRowBreak()) to the sheet mentioned in step #1 * 4. Get a NullPointerException */ public void test38266() throws Exception { String[] files = {"Simple.xls", "SimpleMultiCell.xls", "duprich1.xls"}; for (int i = 0; i < files.length; i++) { FileInputStream in = new FileInputStream(new File(cwd, files[i])); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); HSSFSheet sheet = wb.getSheetAt( 0 ); int[] breaks = sheet.getRowBreaks(); assertNull(breaks); //add 3 row breaks for (int j = 1; j <= 3; j++) { sheet.setRowBreak(j*20); } assertTrue("No Exceptions while adding row breaks in " + files[i], true); } } public void test40738() throws Exception { FileInputStream in = new FileInputStream(new File(cwd, "SimpleWithAutofilter.xls")); HSSFWorkbook wb = new HSSFWorkbook(in); in.close(); //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); out.close(); wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); assertTrue("No Exceptions while reading file", true); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -