From 04dfa8d39f2592299829fff743621b93ff64c965 Mon Sep 17 00:00:00 2001 From: Josh Micich Date: Mon, 25 Aug 2008 22:41:08 +0000 Subject: [PATCH] Replaced calls to deprecated versions of createCell(), getCell(), createRow(), and getRow(). (Changing short to int) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@688910 13f79535-47bb-0310-9956-ffa450edef68 --- .../hssf/usermodel/contrib/HSSFCellUtil.java | 2 +- src/java/org/apache/poi/hssf/dev/HSSF.java | 4 +- .../poi/hssf/extractor/ExcelExtractor.java | 2 +- .../apache/poi/hssf/usermodel/HSSFRow.java | 2 +- .../apache/poi/hssf/usermodel/HSSFSheet.java | 2 +- .../poi/hssf/eventmodel/TestModelFactory.java | 2 +- .../apache/poi/hssf/record/TestSSTRecord.java | 16 +- .../aggregates/TestValueRecordsAggregate.java | 2 +- .../hssf/record/formula/TestAreaErrPtg.java | 2 +- .../poi/hssf/record/formula/TestArrayPtg.java | 2 +- .../poi/hssf/record/formula/TestErrPtg.java | 2 +- .../record/formula/TestIntersectionPtg.java | 2 +- .../hssf/record/formula/TestPercentPtg.java | 6 +- .../poi/hssf/record/formula/TestRangePtg.java | 2 +- .../hssf/record/formula/TestReferencePtg.java | 30 +- .../poi/hssf/record/formula/TestUnionPtg.java | 2 +- .../function/TestReadMissingBuiltInFuncs.java | 2 +- .../poi/hssf/usermodel/TestCellStyle.java | 16 +- .../hssf/usermodel/TestDataValidation.java | 38 +-- .../poi/hssf/usermodel/TestFormulas.java | 262 +++++++++--------- .../poi/hssf/usermodel/TestHSSFCell.java | 6 +- .../poi/hssf/usermodel/TestHSSFComment.java | 8 +- .../poi/hssf/usermodel/TestHSSFHyperlink.java | 34 +-- .../poi/hssf/usermodel/TestHSSFOptimiser.java | 20 +- .../poi/hssf/usermodel/TestHSSFPalette.java | 10 +- .../poi/hssf/usermodel/TestHSSFRow.java | 62 ++--- .../poi/hssf/usermodel/TestHSSFSheet.java | 36 +-- .../poi/hssf/usermodel/TestHSSFWorkbook.java | 8 +- .../hssf/usermodel/TestReadWriteChart.java | 6 +- .../poi/hssf/usermodel/TestSheetHiding.java | 8 +- .../hssf/usermodel/TestSheetShiftRows.java | 42 +-- .../hssf/usermodel/TestUnicodeWorkbook.java | 16 +- .../poi/hssf/usermodel/TestWorkbook.java | 20 +- 33 files changed, 337 insertions(+), 337 deletions(-) diff --git a/src/contrib/src/org/apache/poi/hssf/usermodel/contrib/HSSFCellUtil.java b/src/contrib/src/org/apache/poi/hssf/usermodel/contrib/HSSFCellUtil.java index 67f4b38cb5..8f40ab391e 100644 --- a/src/contrib/src/org/apache/poi/hssf/usermodel/contrib/HSSFCellUtil.java +++ b/src/contrib/src/org/apache/poi/hssf/usermodel/contrib/HSSFCellUtil.java @@ -113,7 +113,7 @@ public final class HSSFCellUtil if ( cell == null ) { - cell = row.createCell( (short)column ); + cell = row.createCell(column ); } return cell; } diff --git a/src/java/org/apache/poi/hssf/dev/HSSF.java b/src/java/org/apache/poi/hssf/dev/HSSF.java index b7d4bbbca6..c6101e313f 100644 --- a/src/java/org/apache/poi/hssf/dev/HSSF.java +++ b/src/java/org/apache/poi/hssf/dev/HSSF.java @@ -131,7 +131,7 @@ public class HSSF { c.setCellStyle(cs); } - c = r.createCell(( short ) (cellnum + 1), + c = r.createCell(cellnum + 1, HSSFCell.CELL_TYPE_STRING); c.setCellValue(new HSSFRichTextString("TEST")); s.setColumnWidth(( short ) (cellnum + 1), @@ -346,7 +346,7 @@ public class HSSF sheet.removeRow(row); } HSSFRow row = sheet.getRow(39); - HSSFCell cell = row.getCell(( short ) 3); + HSSFCell cell = row.getCell(3); cell.setCellType(HSSFCell.CELL_TYPE_STRING); cell.setCellValue("MODIFIED CELL!!!!!"); diff --git a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java index 9a712c40eb..c98757be51 100644 --- a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java +++ b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java @@ -109,7 +109,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor { int firstCell = row.getFirstCellNum(); int lastCell = row.getLastCellNum(); for(int k=firstCell;k 0; x=(short)(x*2) ) { - r = s.createRow((short) x); + r = s.createRow(x); for (short y = 1; y < 256 && y > 0; y= (short) (y +2)) { - c = r.createCell((short) y); + c = r.createCell(y); c.setCellFormula("" + x+"."+y + operator + y +"."+x); } } if (s.getLastRowNum() < Short.MAX_VALUE) { - r = s.createRow((short)0); - c = r.createCell((short)0); + r = s.createRow(0); + c = r.createCell(0); c.setCellFormula("" + Float.MAX_VALUE + operator + Float.MAX_VALUE); } wb.write(out); @@ -216,11 +216,11 @@ public final class TestFormulas extends TestCase { // dont know how to check correct result .. for the moment, we just verify that the file can be read. for (short x = 1; x < Short.MAX_VALUE && x > 0; x=(short)(x*2)) { - r = s.getRow((short) x); + r = s.getRow(x); for (short y = 1; y < 256 && y > 0; y=(short)(y+2)) { - c = r.getCell((short) y); + c = r.getCell(y); assertTrue("got a formula",c.getCellFormula()!=null); assertTrue("loop Formula is as expected "+x+"."+y+operator+y+"."+x+"!="+c.getCellFormula(),( @@ -337,8 +337,8 @@ public final class TestFormulas extends TestCase { HSSFCell c = null; //get our minimum values - r = s.getRow((short)0); - c = r.getCell((short)1); + r = s.getRow(0); + c = r.getCell(1); //get our minimum values assertTrue("minval Formula is as expected A2"+operator+"A3 != "+c.getCellFormula(), ( ("A2"+operator+"A3").equals(c.getCellFormula()) @@ -346,7 +346,7 @@ public final class TestFormulas extends TestCase { for (short x = 1; x < Short.MAX_VALUE && x > 0; x=(short)(x*2)) { - r = s.getRow((short) x); + r = s.getRow(x); for (short y = 1; y < 256 && y > 0; y++) { @@ -372,7 +372,7 @@ public final class TestFormulas extends TestCase { refy2=(short)(y-3); } - c = r.getCell((short) y); + c = r.getCell(y); CellReference cr= new CellReference(refx1, refy1, false, false); ref=cr.formatAsString(); cr=new CellReference(refx2,refy2, false, false); @@ -389,8 +389,8 @@ public final class TestFormulas extends TestCase { } //test our maximum values - r = s.getRow((short)0); - c = r.getCell((short)0); + r = s.getRow(0); + c = r.getCell(0); assertTrue("maxval Formula is as expected",( ("B1"+operator+"IV255").equals(c.getCellFormula()) @@ -416,8 +416,8 @@ public final class TestFormulas extends TestCase { HSSFCell c = null; //get our minimum values - r = s.createRow((short)0); - c = r.createCell((short)1); + r = s.createRow(0); + c = r.createCell(1); c.setCellFormula(formula); wb.write(out); @@ -429,8 +429,8 @@ public final class TestFormulas extends TestCase { s = wb.getSheetAt(0); //get our minimum values - r = s.getRow((short)0); - c = r.getCell((short)1); + r = s.getRow(0); + c = r.getCell(1); assertTrue("minval Formula is as expected", formula.equals(c.getCellFormula()) ); @@ -496,18 +496,18 @@ public final class TestFormulas extends TestCase { HSSFCell c = null; //get our minimum values - r = s.getRow((short)0); - c = r.getCell((short)1); + r = s.getRow(0); + c = r.getCell(1); assertTrue("minval Formula is as expected 1"+operator+"1 != "+c.getCellFormula(), ( ("1"+operator+"1").equals(c.getCellFormula()) )); for (short x = 1; x < Short.MAX_VALUE && x > 0; x=(short)(x*2)) { - r = s.getRow((short) x); + r = s.getRow(x); for (short y = 1; y < 256 && y > 0; y++) { - c = r.getCell((short) y); + c = r.getCell(y); assertTrue("loop Formula is as expected "+x+operator+y+"!="+c.getCellFormula(),( (""+x+operator+y).equals(c.getCellFormula()) @@ -519,8 +519,8 @@ public final class TestFormulas extends TestCase { } //test our maximum values - r = s.getRow((short)0); - c = r.getCell((short)0); + r = s.getRow(0); + c = r.getCell(0); assertTrue("maxval Formula is as expected",( @@ -549,9 +549,9 @@ public final class TestFormulas extends TestCase { HSSFCell c = null; - r = s.createRow((short) 0); + r = s.createRow(0); - c = r.createCell((short) 0); + c = r.createCell(0); c.setCellFormula(function+"(A2:A3)"); @@ -563,7 +563,7 @@ public final class TestFormulas extends TestCase { wb = new HSSFWorkbook(in); s = wb.getSheetAt(0); r = s.getRow(0); - c = r.getCell((short)0); + c = r.getCell(0); assertTrue("function ="+function+"(A2:A3)", ( (function+"(A2:A3)").equals((function+"(A2:A3)")) ) @@ -586,9 +586,9 @@ public final class TestFormulas extends TestCase { HSSFCell c = null; - r = s.createRow((short) 0); + r = s.createRow(0); - c = r.createCell((short) 0); + c = r.createCell(0); c.setCellFormula(function+"(A2,A3)"); @@ -600,7 +600,7 @@ public final class TestFormulas extends TestCase { wb = new HSSFWorkbook(in); s = wb.getSheetAt(0); r = s.getRow(0); - c = r.getCell((short)0); + c = r.getCell(0); assertTrue("function ="+function+"(A2,A3)", ( (function+"(A2,A3)").equals(c.getCellFormula()) ) @@ -624,11 +624,11 @@ public final class TestFormulas extends TestCase { HSSFCell c = null; - r = s.createRow((short) 0); + r = s.createRow(0); - c = r.createCell((short) 0); + c = r.createCell(0); c.setCellFormula(function+"(A2:A4,B2:B4)"); - c=r.createCell((short) 1); + c=r.createCell(1); c.setCellFormula(function+"($A$2:$A4,B$2:B4)"); wb.write(out); @@ -639,13 +639,13 @@ public final class TestFormulas extends TestCase { wb = new HSSFWorkbook(in); s = wb.getSheetAt(0); r = s.getRow(0); - c = r.getCell((short)0); + c = r.getCell(0); assertTrue("function ="+function+"(A2:A4,B2:B4)", ( (function+"(A2:A4,B2:B4)").equals(c.getCellFormula()) ) ); - c=r.getCell((short) 1); + c=r.getCell(1); assertTrue("function ="+function+"($A$2:$A4,B$2:B4)", ( (function+"($A$2:$A4,B$2:B4)").equals(c.getCellFormula()) ) ); @@ -663,17 +663,17 @@ public final class TestFormulas extends TestCase { HSSFCell c = null; - r = s.createRow((short) 0); + r = s.createRow(0); - c = r.createCell((short) 0); + c = r.createCell(0); c.setCellFormula("A3+A2"); - c=r.createCell( (short) 1); + c=r.createCell(1); c.setCellFormula("$A3+$A2"); - c=r.createCell( (short) 2); + c=r.createCell(2); c.setCellFormula("A$3+A$2"); - c=r.createCell( (short) 3); + c=r.createCell(3); c.setCellFormula("$A$3+$A$2"); - c=r.createCell( (short) 4); + c=r.createCell(4); c.setCellFormula("SUM($A$3,$A$2)"); wb.write(out); @@ -684,15 +684,15 @@ public final class TestFormulas extends TestCase { wb = new HSSFWorkbook(in); s = wb.getSheetAt(0); r = s.getRow(0); - c = r.getCell((short)0); + c = r.getCell(0); assertTrue("A3+A2", ("A3+A2").equals(c.getCellFormula())); - c = r.getCell((short)1); + c = r.getCell(1); assertTrue("$A3+$A2", ("$A3+$A2").equals(c.getCellFormula())); - c = r.getCell((short)2); + c = r.getCell(2); assertTrue("A$3+A$2", ("A$3+A$2").equals(c.getCellFormula())); - c = r.getCell((short)3); + c = r.getCell(3); assertTrue("$A$3+$A$2", ("$A$3+$A$2").equals(c.getCellFormula())); - c = r.getCell((short)4); + c = r.getCell(4); assertTrue("SUM($A$3,$A$2)", ("SUM($A$3,$A$2)").equals(c.getCellFormula())); in.close(); } @@ -706,15 +706,15 @@ public final class TestFormulas extends TestCase { HSSFSheet s = wb.createSheet("A"); HSSFRow r = null; HSSFCell c = null; - r = s.createRow((short)0); - c = r.createCell((short)0);c.setCellValue(1); - c = r.createCell((short)1);c.setCellValue(2); + r = s.createRow(0); + c = r.createCell(0);c.setCellValue(1); + c = r.createCell(1);c.setCellValue(2); s = wb.createSheet("B"); - r = s.createRow((short)0); - c=r.createCell((short)0); c.setCellFormula("AVERAGE(A!A1:B1)"); - c=r.createCell((short)1); c.setCellFormula("A!A1+A!B1"); - c=r.createCell((short)2); c.setCellFormula("A!$A$1+A!$B1"); + r = s.createRow(0); + c=r.createCell(0); c.setCellFormula("AVERAGE(A!A1:B1)"); + c=r.createCell(1); c.setCellFormula("A!A1+A!B1"); + c=r.createCell(2); c.setCellFormula("A!$A$1+A!$B1"); wb.write(out); out.close(); @@ -724,9 +724,9 @@ public final class TestFormulas extends TestCase { wb = new HSSFWorkbook(in); s = wb.getSheet("B"); r = s.getRow(0); - c = r.getCell((short)0); + c = r.getCell(0); assertTrue("expected: AVERAGE(A!A1:B1) got: "+c.getCellFormula(), ("AVERAGE(A!A1:B1)").equals(c.getCellFormula())); - c = r.getCell((short)1); + c = r.getCell(1); assertTrue("expected: A!A1+A!B1 got: "+c.getCellFormula(), ("A!A1+A!B1").equals(c.getCellFormula())); in.close(); } @@ -740,29 +740,29 @@ public final class TestFormulas extends TestCase { HSSFCell c = null; - r = s.createRow((short) 0); + r = s.createRow(0); - c = r.createCell((short) 0); + c = r.createCell(0); c.setCellFormula("A3+A2"); - c=r.createCell( (short) 1); + c=r.createCell(1); c.setCellFormula("AVERAGE(A3,A2)"); - c=r.createCell( (short) 2); + c=r.createCell(2); c.setCellFormula("ROW(A3)"); - c=r.createCell( (short) 3); + c=r.createCell(3); c.setCellFormula("AVERAGE(A2:A3)"); - c=r.createCell( (short) 4); + c=r.createCell(4); c.setCellFormula("POWER(A2,A3)"); - c=r.createCell( (short) 5); + c=r.createCell(5); c.setCellFormula("SIN(A2)"); - c=r.createCell( (short) 6); + c=r.createCell(6); c.setCellFormula("SUM(A2:A3)"); - c=r.createCell( (short) 7); + c=r.createCell(7); c.setCellFormula("SUM(A2,A3)"); - r = s.createRow((short) 1);c=r.createCell( (short) 0); c.setCellValue(2.0); - r = s.createRow((short) 2);c=r.createCell( (short) 0); c.setCellValue(3.0); + r = s.createRow(1);c=r.createCell(0); c.setCellValue(2.0); + r = s.createRow(2);c=r.createCell(0); c.setCellValue(3.0); wb.write(out); out.close(); @@ -778,10 +778,10 @@ public final class TestFormulas extends TestCase { HSSFSheet s = wb.createSheet("A"); HSSFRow r = null; HSSFCell c = null; - r = s.createRow((short)0); - c=r.createCell((short)1); c.setCellFormula("UPPER(\"abc\")"); - c=r.createCell((short)2); c.setCellFormula("LOWER(\"ABC\")"); - c=r.createCell((short)3); c.setCellFormula("CONCATENATE(\" my \",\" name \")"); + r = s.createRow(0); + c=r.createCell(1); c.setCellFormula("UPPER(\"abc\")"); + c=r.createCell(2); c.setCellFormula("LOWER(\"ABC\")"); + c=r.createCell(3); c.setCellFormula("CONCATENATE(\" my \",\" name \")"); wb.write(out); out.close(); @@ -789,7 +789,7 @@ public final class TestFormulas extends TestCase { wb = openSample("StringFormulas.xls"); s = wb.getSheetAt(0); r = s.getRow(0); - c = r.getCell((short)0); + c = r.getCell(0); assertTrue("expected: UPPER(\"xyz\") got "+c.getCellFormula(), ("UPPER(\"xyz\")").equals(c.getCellFormula())); //c = r.getCell((short)1); //assertTrue("expected: A!A1+A!B1 got: "+c.getCellFormula(), ("A!A1+A!B1").equals(c.getCellFormula())); @@ -807,8 +807,8 @@ public final class TestFormulas extends TestCase { HSSFSheet s = wb.createSheet("A"); HSSFRow r = null; HSSFCell c = null; - r = s.createRow((short)0); - c=r.createCell((short)1); c.setCellFormula("IF(A1 blank // 5 -> num - row.createCell((short)0).setCellValue(new HSSFRichTextString("test")); - row.createCell((short)1).setCellValue(3.2); - row.createCell((short)4, HSSFCell.CELL_TYPE_BLANK); - row.createCell((short)5).setCellValue(4); + row.createCell(0).setCellValue(new HSSFRichTextString("test")); + row.createCell(1).setCellValue(3.2); + row.createCell(4, HSSFCell.CELL_TYPE_BLANK); + row.createCell(5).setCellValue(4); // First up, no policy given, uses default assertEquals(HSSFCell.CELL_TYPE_STRING, row.getCell(0).getCellType()); @@ -281,12 +281,12 @@ public final class TestHSSFRow extends TestCase { public void testRowHeight() { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(); - HSSFRow row1 = sheet.createRow( (short) 0); + HSSFRow row1 = sheet.createRow(0); assertEquals(0xFF, row1.getHeight()); assertEquals(sheet.getDefaultRowHeight(), row1.getHeight()); - HSSFRow row2 = sheet.createRow( (short) 1); + HSSFRow row2 = sheet.createRow(1); row2.setHeight((short)400); assertEquals(400, row2.getHeight()); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 1550f77216..9507885bd4 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -146,10 +146,10 @@ public final class TestHSSFSheet extends TestCase { public void testReadBooleans() { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Test boolean"); - HSSFRow row = sheet.createRow((short) 2); - HSSFCell cell = row.createCell((short) 9); + HSSFRow row = sheet.createRow(2); + HSSFCell cell = row.createCell(9); cell.setCellValue(true); - cell = row.createCell((short) 11); + cell = row.createCell(11); cell.setCellValue(true); workbook = HSSFTestDataSamples.writeOutAndReadBack(workbook); @@ -163,7 +163,7 @@ public final class TestHSSFSheet extends TestCase { public void testRemoveRow() { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Test boolean"); - HSSFRow row = sheet.createRow((short) 2); + HSSFRow row = sheet.createRow(2); sheet.removeRow(row); } @@ -185,8 +185,8 @@ public final class TestHSSFSheet extends TestCase { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Test Clone"); HSSFRow row = sheet.createRow(0); - HSSFCell cell = row.createCell((short) 0); - HSSFCell cell2 = row.createCell((short) 1); + HSSFCell cell = row.createCell(0); + HSSFCell cell2 = row.createCell(1); cell.setCellValue(new HSSFRichTextString("clone_test")); cell2.setCellFormula("sin(1)"); @@ -215,8 +215,8 @@ public final class TestHSSFSheet extends TestCase { public void testCloneSheetMultipleTimes() { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Test Clone"); - HSSFRow row = sheet.createRow((short) 0); - HSSFCell cell = row.createCell((short) 0); + HSSFRow row = sheet.createRow(0); + HSSFCell cell = row.createCell(0); cell.setCellValue(new HSSFRichTextString("clone_test")); //Clone the sheet multiple times workbook.cloneSheet(0); @@ -509,11 +509,11 @@ public final class TestHSSFSheet extends TestCase { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); HSSFRow row = sheet.createRow(0); - HSSFCell cell = row.createCell((short)0); + HSSFCell cell = row.createCell(0); cell.setCellValue(new HSSFRichTextString("first row, first cell")); row = sheet.createRow(1); - cell = row.createCell((short)1); + cell = row.createCell(1); cell.setCellValue(new HSSFRichTextString("second row, second cell")); CellRangeAddress region = new CellRangeAddress(1, 1, 0, 1); @@ -616,13 +616,13 @@ public final class TestHSSFSheet extends TestCase { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = wb.createSheet("Sheet1"); HSSFRow r = s.createRow(0); - r.createCell((short) 0).setCellValue(1); - r.createCell((short) 1).setCellFormula("A1*2"); + r.createCell(0).setCellValue(1); + r.createCell(1).setCellFormula("A1*2"); HSSFSheet s1 = wb.cloneSheet(0); r = s1.getRow(0); - assertEquals("double", r.getCell((short) 0).getNumericCellValue(), 1, 0); // sanity check - assertNotNull(r.getCell((short) 1)); - assertEquals("formula", r.getCell((short) 1).getCellFormula(), "A1*2"); + assertEquals("double", r.getCell(0).getNumericCellValue(), 1, 0); // sanity check + assertNotNull(r.getCell(1)); + assertEquals("formula", r.getCell(1).getCellFormula(), "A1*2"); } /** test that new default column styles get applied */ @@ -632,7 +632,7 @@ public final class TestHSSFSheet extends TestCase { HSSFSheet s = wb.createSheet(); s.setDefaultColumnStyle((short) 0, style); HSSFRow r = s.createRow(0); - HSSFCell c = r.createCell((short) 0); + HSSFCell c = r.createCell(0); assertEquals("style should match", style.getIndex(), c.getCellStyle().getIndex()); } @@ -709,8 +709,8 @@ public final class TestHSSFSheet extends TestCase { HSSFSheet sheet = workbook.getSheetAt(0); HSSFSheet sheet2 = workbook.getSheetAt(0); HSSFRow row = sheet.getRow(0); - row.createCell((short) 0).setCellValue(5); - row.createCell((short) 1).setCellValue(8); + row.createCell(0).setCellValue(5); + row.createCell(1).setCellValue(8); assertFalse(sheet.getForceFormulaRecalculation()); assertFalse(sheet2.getForceFormulaRecalculation()); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java index 35a2d955fb..658a3f4884 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -290,10 +290,10 @@ public final class TestHSSFWorkbook extends TestCase { assertEquals(true, sheet3.isActive()); if (false) { // helpful if viewing this workbook in excel: - sheet1.createRow(0).createCell((short)0).setCellValue(new HSSFRichTextString("Sheet1")); - sheet2.createRow(0).createCell((short)0).setCellValue(new HSSFRichTextString("Sheet2")); - sheet3.createRow(0).createCell((short)0).setCellValue(new HSSFRichTextString("Sheet3")); - sheet4.createRow(0).createCell((short)0).setCellValue(new HSSFRichTextString("Sheet4")); + sheet1.createRow(0).createCell(0).setCellValue(new HSSFRichTextString("Sheet1")); + sheet2.createRow(0).createCell(0).setCellValue(new HSSFRichTextString("Sheet2")); + sheet3.createRow(0).createCell(0).setCellValue(new HSSFRichTextString("Sheet3")); + sheet4.createRow(0).createCell(0).setCellValue(new HSSFRichTextString("Sheet4")); try { File fOut = TempFile.createTempFile("sheetMultiSelect", ".xls"); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java b/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java index 342f6e26f1..186ee18a6b 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java @@ -39,14 +39,14 @@ public final class TestReadWriteChart extends TestCase { HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("SimpleChart.xls"); HSSFSheet sheet = workbook.getSheetAt(0); HSSFRow firstRow = sheet.getRow(0); - HSSFCell firstCell = firstRow.getCell(( short ) 0); + HSSFCell firstCell = firstRow.getCell(0); //System.out.println("first assertion for date"); assertEquals(new GregorianCalendar(2000, 0, 1, 10, 51, 2).getTime(), HSSFDateUtil .getJavaDate(firstCell.getNumericCellValue(), false)); - HSSFRow row = sheet.createRow(( short ) 15); - HSSFCell cell = row.createCell(( short ) 1); + HSSFRow row = sheet.createRow(15); + HSSFCell cell = row.createCell(1); cell.setCellValue(22); Sheet newSheet = workbook.getSheetAt(0).getSheet(); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java b/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java index 62a26e90b5..ddd9101593 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java @@ -61,10 +61,10 @@ public final class TestSheetHiding extends TestCase { assertEquals(1, wbU.getSheetAt(1).getRow(0).getLastCellNum()); // Text should be sheet based - assertEquals("Sheet1A1", wbH.getSheetAt(0).getRow(0).getCell((short)0).getRichStringCellValue().getString()); - assertEquals("Sheet2A1", wbH.getSheetAt(1).getRow(0).getCell((short)0).getRichStringCellValue().getString()); - assertEquals("Sheet1A1", wbU.getSheetAt(0).getRow(0).getCell((short)0).getRichStringCellValue().getString()); - assertEquals("Sheet2A1", wbU.getSheetAt(1).getRow(0).getCell((short)0).getRichStringCellValue().getString()); + assertEquals("Sheet1A1", wbH.getSheetAt(0).getRow(0).getCell(0).getRichStringCellValue().getString()); + assertEquals("Sheet2A1", wbH.getSheetAt(1).getRow(0).getCell(0).getRichStringCellValue().getString()); + assertEquals("Sheet1A1", wbU.getSheetAt(0).getRow(0).getCell(0).getRichStringCellValue().getString()); + assertEquals("Sheet2A1", wbU.getSheetAt(1).getRow(0).getCell(0).getRichStringCellValue().getString()); } /** diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestSheetShiftRows.java b/src/testcases/org/apache/poi/hssf/usermodel/TestSheetShiftRows.java index 03d67cc21c..101bd325df 100755 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestSheetShiftRows.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestSheetShiftRows.java @@ -99,8 +99,8 @@ public final class TestSheetShiftRows extends TestCase { public void testShiftRow(){ HSSFWorkbook b = new HSSFWorkbook(); HSSFSheet s = b.createSheet(); - s.createRow(0).createCell((short)0).setCellValue("TEST1"); - s.createRow(3).createCell((short)0).setCellValue("TEST2"); + s.createRow(0).createCell(0).setCellValue("TEST1"); + s.createRow(3).createCell(0).setCellValue("TEST2"); s.shiftRows(0,4,1); } @@ -112,8 +112,8 @@ public final class TestSheetShiftRows extends TestCase { public void testShiftRow0(){ HSSFWorkbook b = new HSSFWorkbook(); HSSFSheet s = b.createSheet(); - s.createRow(0).createCell((short)0).setCellValue("TEST1"); - s.createRow(3).createCell((short)0).setCellValue("TEST2"); + s.createRow(0).createCell(0).setCellValue("TEST1"); + s.createRow(3).createCell(0).setCellValue("TEST2"); s.shiftRows(0,4,1); } @@ -125,7 +125,7 @@ public final class TestSheetShiftRows extends TestCase { HSSFWorkbook b = new HSSFWorkbook(); HSSFSheet s = b.createSheet(); HSSFRow row = s.createRow(4); - row.createCell((short)0).setCellValue("test"); + row.createCell(0).setCellValue("test"); s.setRowBreak(4); s.shiftRows(4, 4, 2); @@ -203,34 +203,34 @@ public final class TestSheetShiftRows extends TestCase { HSSFSheet sheet = wb.getSheet("Sheet1"); assertEquals(19, sheet.getLastRowNum()); - assertEquals("cell B1 (ref)", sheet.getRow(0).getCell((short)3).getRichStringCellValue().toString()); - assertEquals("CONCATENATE(B1,\" (ref)\")", sheet.getRow(0).getCell((short)3).getCellFormula()); - assertEquals("cell B2 (ref)", sheet.getRow(1).getCell((short)3).getRichStringCellValue().toString()); - assertEquals("CONCATENATE(B2,\" (ref)\")", sheet.getRow(1).getCell((short)3).getCellFormula()); - assertEquals("cell B3 (ref)", sheet.getRow(2).getCell((short)3).getRichStringCellValue().toString()); - assertEquals("CONCATENATE(B3,\" (ref)\")", sheet.getRow(2).getCell((short)3).getCellFormula()); - assertEquals("cell B2 (ref)", sheet.getRow(6).getCell((short)1).getRichStringCellValue().toString()); - assertEquals("CONCATENATE(B2,\" (ref)\")", sheet.getRow(6).getCell((short)1).getCellFormula()); + assertEquals("cell B1 (ref)", sheet.getRow(0).getCell(3).getRichStringCellValue().toString()); + assertEquals("CONCATENATE(B1,\" (ref)\")", sheet.getRow(0).getCell(3).getCellFormula()); + assertEquals("cell B2 (ref)", sheet.getRow(1).getCell(3).getRichStringCellValue().toString()); + assertEquals("CONCATENATE(B2,\" (ref)\")", sheet.getRow(1).getCell(3).getCellFormula()); + assertEquals("cell B3 (ref)", sheet.getRow(2).getCell(3).getRichStringCellValue().toString()); + assertEquals("CONCATENATE(B3,\" (ref)\")", sheet.getRow(2).getCell(3).getCellFormula()); + assertEquals("cell B2 (ref)", sheet.getRow(6).getCell(1).getRichStringCellValue().toString()); + assertEquals("CONCATENATE(B2,\" (ref)\")", sheet.getRow(6).getCell(1).getCellFormula()); sheet.shiftRows(1, 1, 10); // Row 1 => Row 11 // So strings on row 11 unchanged, but reference in formula is - assertEquals("cell B1 (ref)", sheet.getRow(0).getCell((short)3).getRichStringCellValue().toString()); - assertEquals("CONCATENATE(B1,\" (ref)\")", sheet.getRow(0).getCell((short)3).getCellFormula()); + assertEquals("cell B1 (ref)", sheet.getRow(0).getCell(3).getRichStringCellValue().toString()); + assertEquals("CONCATENATE(B1,\" (ref)\")", sheet.getRow(0).getCell(3).getCellFormula()); assertEquals(0, sheet.getRow(1).getPhysicalNumberOfCells()); // still save b2 - assertEquals("cell B2 (ref)", sheet.getRow(11).getCell((short)3).getRichStringCellValue().toString()); + assertEquals("cell B2 (ref)", sheet.getRow(11).getCell(3).getRichStringCellValue().toString()); // but points to b12 - assertEquals("CONCATENATE(B12,\" (ref)\")", sheet.getRow(11).getCell((short)3).getCellFormula()); + assertEquals("CONCATENATE(B12,\" (ref)\")", sheet.getRow(11).getCell(3).getCellFormula()); - assertEquals("cell B3 (ref)", sheet.getRow(2).getCell((short)3).getRichStringCellValue().toString()); - assertEquals("CONCATENATE(B3,\" (ref)\")", sheet.getRow(2).getCell((short)3).getCellFormula()); + assertEquals("cell B3 (ref)", sheet.getRow(2).getCell(3).getRichStringCellValue().toString()); + assertEquals("CONCATENATE(B3,\" (ref)\")", sheet.getRow(2).getCell(3).getCellFormula()); // one on a non-shifted row also updated - assertEquals("cell B2 (ref)", sheet.getRow(6).getCell((short)1).getRichStringCellValue().toString()); - assertEquals("CONCATENATE(B12,\" (ref)\")", sheet.getRow(6).getCell((short)1).getCellFormula()); + assertEquals("cell B2 (ref)", sheet.getRow(6).getCell(1).getRichStringCellValue().toString()); + assertEquals("CONCATENATE(B12,\" (ref)\")", sheet.getRow(6).getCell(1).getCellFormula()); } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java index d67c3f4693..2a92152857 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java @@ -57,14 +57,14 @@ public class TestUnicodeWorkbook extends TestCase { f.setRight("\u20ac"); HSSFRow r = s.createRow(0); - HSSFCell c = r.createCell((short)1); + HSSFCell c = r.createCell(1); c.setCellValue(12.34); c.getCellStyle().setDataFormat(fmt); - HSSFCell c2 = r.createCell((short)2); + HSSFCell c2 = r.createCell(2); c.setCellValue(new HSSFRichTextString("\u20ac")); - HSSFCell c3 = r.createCell((short)3); + HSSFCell c3 = r.createCell(3); String formulaString = "TEXT(12.34,\"\u20ac###,##\")"; c3.setCellFormula(formulaString); @@ -95,16 +95,16 @@ public class TestUnicodeWorkbook extends TestCase { //Test the dataformat r = s.getRow(0); - c = r.getCell((short)1); + c = r.getCell(1); df = wb.createDataFormat(); assertEquals(formatStr, df.getFormat(c.getCellStyle().getDataFormat())); //Test the cell string value - c2 = r.getCell((short)2); + c2 = r.getCell(2); assertEquals(c.getRichStringCellValue().getString(), "\u20ac"); //Test the cell formula - c3 = r.getCell((short)3); + c3 = r.getCell(3); assertEquals(c3.getCellFormula(), formulaString); } @@ -122,7 +122,7 @@ public class TestUnicodeWorkbook extends TestCase { HSSFSheet s = wb.createSheet("test"); HSSFRow r = s.createRow(0); - HSSFCell c = r.createCell((short)1); + HSSFCell c = r.createCell(1); c.setCellValue(new HSSFRichTextString("\u00e4")); //Confirm that the sring will be compressed @@ -140,7 +140,7 @@ public class TestUnicodeWorkbook extends TestCase { s = wb.getSheet("test"); assertNotNull(s); - c = r.getCell((short)1); + c = r.getCell(1); assertEquals(c.getRichStringCellValue().getString(), "\u00e4"); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java index ebbe6cbc00..416d4127a0 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java @@ -95,7 +95,7 @@ public final class TestWorkbook extends TestCase { c.setCellValue(rownum * 10000 + cellnum + ((( double ) rownum / 1000) + (( double ) cellnum / 10000))); - c = r.createCell(( short ) (cellnum + 1)); + c = r.createCell(cellnum + 1); c.setCellValue(new HSSFRichTextString("TEST")); } } @@ -141,7 +141,7 @@ public final class TestWorkbook extends TestCase { c.setCellValue(rownum * 10000 + cellnum + ((( double ) rownum / 1000) + (( double ) cellnum / 10000))); - c = r.createCell(( short ) (cellnum + 1)); + c = r.createCell(cellnum + 1); c.setCellValue(new HSSFRichTextString("TEST")); } } @@ -225,8 +225,8 @@ public final class TestWorkbook extends TestCase { short df = format.getFormat("0.0"); cs.setDataFormat(df); - r = s.createRow((short)0); - c = r.createCell((short)0); + r = s.createRow(0); + c = r.createCell(0); c.setCellStyle(cs); c.setCellValue(1.25); @@ -238,7 +238,7 @@ public final class TestWorkbook extends TestCase { HSSFWorkbook workbook = new HSSFWorkbook(fs); HSSFSheet sheet = workbook.getSheetAt(0); HSSFCell cell = - sheet.getRow(( short ) 0).getCell(( short ) 0); + sheet.getRow(0).getCell(0); format = workbook.createDataFormat(); assertEquals(1.25,cell.getNumericCellValue(), 1e-10); @@ -349,7 +349,7 @@ public final class TestWorkbook extends TestCase { for (int k = 0; k < 4; k++) { - HSSFCell cell = sheet.getRow(( short ) k).getCell(( short ) 0); + HSSFCell cell = sheet.getRow(k).getCell(0); cell.setCellValue(new HSSFRichTextString(REPLACED)); } @@ -359,7 +359,7 @@ public final class TestWorkbook extends TestCase { sheet = workbook.getSheetAt(0); for (int k = 0; k < 4; k++) { - HSSFCell cell = sheet.getRow(( short ) k).getCell(( short ) 0); + HSSFCell cell = sheet.getRow(k).getCell(0); assertEquals(REPLACED, cell.getRichStringCellValue().getString()); } @@ -438,7 +438,7 @@ public final class TestWorkbook extends TestCase { c.setCellValue(rownum * 10000 + cellnum + ((( double ) rownum / 1000) + (( double ) cellnum / 10000))); - c = r.createCell(( short ) (cellnum + 1)); + c = r.createCell(cellnum + 1); c.setCellValue(new HSSFRichTextString("TEST")); } } @@ -529,7 +529,7 @@ public final class TestWorkbook extends TestCase { for ( i = 0, j = 32771; j > 0; i++, j-- ) { row = sheet.createRow(i); - cell = row.createCell((short) 0); + cell = row.createCell(0); cell.setCellValue(i); } sanityChecker.checkHSSFWorkbook(workbook); @@ -555,7 +555,7 @@ public final class TestWorkbook extends TestCase { HSSFRow row = sheet.createRow(0); - HSSFCell cell = row.createCell((short)1); + HSSFCell cell = row.createCell(1); cell.setCellValue(new HSSFRichTextString("hi")); -- 2.39.5