aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/usermodel
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-08-27 10:34:33 +0000
committerNick Burch <nick@apache.org>2008-08-27 10:34:33 +0000
commitab3de58257edddff10886d2f0830c07fbdf9abc8 (patch)
tree8ac7344f0b825d722aba854b57566f8d584d66ca /src/testcases/org/apache/poi/hssf/usermodel
parent48ef5fb2d3523381ad6ef2c135b7625860a5d9f3 (diff)
downloadpoi-ab3de58257edddff10886d2f0830c07fbdf9abc8.tar.gz
poi-ab3de58257edddff10886d2f0830c07fbdf9abc8.zip
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-653891,653893-653944,653946-654055,654057-654355,654357-654365,654367-654648,654651-655215,655217-655277,655279-655281,655283-655911,655913-656212,656214,656216-656251,656253-656698,656700-656756,656758-656892,656894-657135,657137-657165,657168-657179,657181-657354,657356-657357,657359-657701,657703-657874,657876-658032,658034-658284,658286,658288-658301,658303-658307,658309-658321,658323-658335,658337-658348,658351,658353-658832,658834-658983,658985,658987-659066,659068-659402,659404-659428,659430-659451,659453-659454,659456-659461,659463-659477,659479-659524,659526-659571,659574,659576-660255,660257-660262,660264-660279,660281-660343,660345-660473,660475-660827,660829-660833,660835-660888,660890-663321,663323-663435,663437-663764,663766-663854,663856-664219,664221-664489,664494-664514,664516-668013,668015-668142,668144-668152,668154,668156-668256,668258,668260-669139,669141-669455,669457-669657,669659-669808,669810-670189,670191-671321,671323-672229,672231-672549,672551-672552,672554-672561,672563-672566,672568,672571-673049,673051-673852,673854-673862,673864-673986,673988-673996,673998-674347,674349-674890,674892-674910,674912-674936,674938-674952,674954-675078,675080-675085,675087-675217,675219-675660,675662-675670,675672-675716,675718-675726,675728-675733,675735-675775,675777-675782,675784,675786-675791,675794-675852,675854-676200,676202,676204,676206-676220,676222-676309,676311-676456,676458-676994,676996-677027,677030-677040,677042-677056,677058-677375,677377-677968,677970-677971,677973,677975-677994,677996-678286,678288-678538,678540-680393,680395-680469,680471-680529,680531-680852,680854-681529,681531-681571,681573-682224,682226,682228,682231-682281,682283-682335,682337-682507,682509,682512-682517,682519-682532,682534-682619,682622-682777,682779-682998,683000-683019,683021-683022,683024-683080,683082-683092,683094-683095,683097-683127,683129-683131,683133-683166,683168-683698,683700-683705,683707-683757,683759-683787,683789-683870,683872-683879,683881-683900,683902-684066,684068-684074,684076-684222,684224-684254,684257-684281,684283-684286,684288-684292,684294-684298,684300-684301,684303-684308,684310-684317,684320,684323-684335,684337-684348,684350-684354,684356-684361,684363-684369,684371-684453,684455-684883,684885-684937,684940-684958,684960-684970,684972-684985,684987-685053,685055-685063,685065-685259,685261-685262,685264-685266,685268-685282,685285-686035,686037-686045,686047-686052,686054-686206,686208-686215,686217-686277,686279-686289,686291-686620,686622-686623,686626-686627,686629-686639,686641-686843,686845-686976,686978-689430 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk ........ r687403 | nick | 2008-08-20 19:14:11 +0100 (Wed, 20 Aug 2008) | 1 line Make an initial start on hpbf code ........ r687423 | nick | 2008-08-20 19:50:15 +0100 (Wed, 20 Aug 2008) | 1 line More HPBF stuff, and some tests ........ r687429 | nick | 2008-08-20 20:40:05 +0100 (Wed, 20 Aug 2008) | 1 line Quill CONTENTS bits, and tests ........ r687443 | nick | 2008-08-20 21:13:08 +0100 (Wed, 20 Aug 2008) | 1 line HPBF text extractor and unit tests ........ r688426 | josh | 2008-08-23 23:47:51 +0100 (Sat, 23 Aug 2008) | 1 line Fix for bug 45672 - prevent MissingRecordAwareHSSFListener generating multiple LastCellOfRowDummyRecords when shared formulas are present ........ r688642 | josh | 2008-08-25 08:56:37 +0100 (Mon, 25 Aug 2008) | 1 line JDK 1.4 fixes for new hpbf stuff. Some clean-up ........ r688650 | josh | 2008-08-25 09:09:02 +0100 (Mon, 25 Aug 2008) | 1 line Initial support for evaluating external add-in functions like YEARFRAC ........ r688655 | josh | 2008-08-25 09:30:54 +0100 (Mon, 25 Aug 2008) | 1 line Fix for bug 45682 - allow cloning of sheets with conditional formatting ........ r688825 | josh | 2008-08-25 19:57:14 +0100 (Mon, 25 Aug 2008) | 1 line Fix for small bug introduced in c688655 - keep header field in sync with number of rules ........ r688910 | josh | 2008-08-25 23:41:08 +0100 (Mon, 25 Aug 2008) | 1 line 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/branches/ooxml@689435 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java16
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java38
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java262
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java6
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java8
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java41
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java115
-rwxr-xr-xsrc/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java34
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java20
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java10
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java62
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java36
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java8
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java6
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java8
-rwxr-xr-xsrc/testcases/org/apache/poi/hssf/usermodel/TestSheetShiftRows.java42
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java16
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java20
18 files changed, 402 insertions, 346 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
index 39b949f7de..1dc826cc6f 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
@@ -85,7 +85,7 @@ public class TestCellStyle
c.setCellValue(rownum * 10000 + cellnum
+ ((( double ) rownum / 1000)
+ (( double ) cellnum / 10000)));
- c = r.createCell(( short ) (cellnum + 1));
+ c = r.createCell(cellnum + 1);
c.setCellValue("TEST");
c.setCellStyle(cs);
}
@@ -112,16 +112,16 @@ public class TestCellStyle
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();
HSSFCellStyle cs = wb.createCellStyle();
- HSSFRow row = s.createRow((short)0);
+ HSSFRow row = s.createRow(0);
// with Date:
- HSSFCell cell = row.createCell((short)1);
+ HSSFCell cell = row.createCell(1);
cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
cell.setCellStyle(cs);
cell.setCellValue(new Date());
// with Calendar:
- cell = row.createCell((short)2);
+ cell = row.createCell(2);
cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
cell.setCellStyle(cs);
Calendar cal = Calendar.getInstance();
@@ -143,9 +143,9 @@ public class TestCellStyle
HSSFSheet s = wb.createSheet();
HSSFCellStyle cs1 = wb.createCellStyle();
HSSFCellStyle cs2 = wb.createCellStyle();
- HSSFRow row = s.createRow((short)0);
- HSSFCell cell1 = row.createCell((short)1);
- HSSFCell cell2 = row.createCell((short)2);
+ HSSFRow row = s.createRow(0);
+ HSSFCell cell1 = row.createCell(1);
+ HSSFCell cell2 = row.createCell(2);
cs1.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/dd/yy"));
@@ -215,7 +215,7 @@ public class TestCellStyle
+ ((( double ) rownum / 1000)
+ (( double ) cellnum / 10000)));
c.setCellStyle(cs);
- c = r.createCell(( short ) (cellnum + 1));
+ c = r.createCell(cellnum + 1);
c.setCellValue("TEST");
c.setCellStyle(cs2);
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java b/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
index 299372c121..15a5b8250f 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
@@ -111,7 +111,7 @@ public final class TestDataValidation extends TestCase {
inputBox, errorBox);
if (_cellStyle != null) {
HSSFRow row = _sheet.getRow(_sheet.getPhysicalNumberOfRows() - 1);
- HSSFCell cell = row.createCell((short) 0);
+ HSSFCell cell = row.createCell(0);
cell.setCellStyle(_cellStyle);
}
writeOtherSettings(_sheet, _style_1, promptDescr);
@@ -144,26 +144,26 @@ public final class TestDataValidation extends TestCase {
boolean errorBox) {
HSSFRow row = sheet.createRow(sheet.getPhysicalNumberOfRows());
// condition's string
- HSSFCell cell = row.createCell((short) 1);
+ HSSFCell cell = row.createCell(1);
cell.setCellStyle(style_1);
setCellValue(cell, strCondition);
// allow empty cells
- cell = row.createCell((short) 2);
+ cell = row.createCell(2);
cell.setCellStyle(style_2);
setCellValue(cell, ((allowEmpty) ? "yes" : "no"));
// show input box
- cell = row.createCell((short) 3);
+ cell = row.createCell(3);
cell.setCellStyle(style_2);
setCellValue(cell, ((inputBox) ? "yes" : "no"));
// show error box
- cell = row.createCell((short) 4);
+ cell = row.createCell(4);
cell.setCellStyle(style_2);
setCellValue(cell, ((errorBox) ? "yes" : "no"));
}
private static void writeOtherSettings(HSSFSheet sheet, HSSFCellStyle style,
String strStettings) {
HSSFRow row = sheet.getRow(sheet.getPhysicalNumberOfRows() - 1);
- HSSFCell cell = row.createCell((short) 5);
+ HSSFCell cell = row.createCell(5);
cell.setCellStyle(style);
setCellValue(cell, strStettings);
}
@@ -256,7 +256,7 @@ public final class TestDataValidation extends TestCase {
HSSFRow row = sheet.createRow(sheet.getPhysicalNumberOfRows());
row = sheet.createRow(sheet.getPhysicalNumberOfRows());
sheet.addMergedRegion(new CellRangeAddress(sheet.getPhysicalNumberOfRows()-1, sheet.getPhysicalNumberOfRows()-1, 0, 5));
- HSSFCell cell = row.createCell((short) 0);
+ HSSFCell cell = row.createCell(0);
setCellValue(cell, strTypeDescription);
cell.setCellStyle(_style_3);
row = sheet.createRow(sheet.getPhysicalNumberOfRows());
@@ -267,7 +267,7 @@ public final class TestDataValidation extends TestCase {
HSSFRow row = sheet.createRow(sheet.getPhysicalNumberOfRows());
row.setHeight((short) 400);
for (int i = 0; i < 6; i++) {
- row.createCell((short) i).setCellStyle(_style_4);
+ row.createCell(i).setCellStyle(_style_4);
if (i == 2 || i == 3 || i == 4) {
sheet.setColumnWidth((short) i, (short) 3500);
} else if (i == 5) {
@@ -276,17 +276,17 @@ public final class TestDataValidation extends TestCase {
sheet.setColumnWidth((short) i, (short) 8000);
}
}
- HSSFCell cell = row.getCell((short) 0);
+ HSSFCell cell = row.getCell(0);
setCellValue(cell, "Data validation cells");
- cell = row.getCell((short) 1);
+ cell = row.getCell(1);
setCellValue(cell, "Condition");
- cell = row.getCell((short) 2);
+ cell = row.getCell(2);
setCellValue(cell, "Allow blank");
- cell = row.getCell((short) 3);
+ cell = row.getCell(3);
setCellValue(cell, "Prompt box");
- cell = row.getCell((short) 4);
+ cell = row.getCell(4);
setCellValue(cell, "Error box");
- cell = row.getCell((short) 5);
+ cell = row.getCell(5);
setCellValue(cell, "Other settings");
}
@@ -298,7 +298,7 @@ public final class TestDataValidation extends TestCase {
HSSFSheet sheet = _currentSheet;
HSSFRow row = sheet.getRow(sheet.getPhysicalNumberOfRows()-1);
sheet.addMergedRegion(new CellRangeAddress(sheet.getPhysicalNumberOfRows()-1, sheet.getPhysicalNumberOfRows()-1, 0, 5));
- HSSFCell cell = row.createCell((short)0);
+ HSSFCell cell = row.createCell(0);
setCellValue(cell, strTypeDescription);
cell.setCellStyle(_style_3);
row = sheet.createRow(sheet.getPhysicalNumberOfRows());
@@ -395,14 +395,14 @@ public final class TestDataValidation extends TestCase {
// add list data on same sheet
for (int i = 0; i < 10; i++) {
HSSFRow currRow = fSheet.createRow(i + 29);
- setCellValue(currRow.createCell((short) 0), cellStrValue);
+ setCellValue(currRow.createCell(0), cellStrValue);
}
// add list data on another sheet
for (int i = 0; i < 10; i++) {
HSSFRow currRow = dataSheet.createRow(i + 0);
- setCellValue(currRow.createCell((short) 0), "Data a" + i);
- setCellValue(currRow.createCell((short) 1), "Data b" + i);
- setCellValue(currRow.createCell((short) 2), "Data c" + i);
+ setCellValue(currRow.createCell(0), "Data a" + i);
+ setCellValue(currRow.createCell(1), "Data b" + i);
+ setCellValue(currRow.createCell(2), "Data c" + i);
}
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
index 3fdc1a9dba..36eaf92f32 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
@@ -54,8 +54,8 @@ public final class TestFormulas extends TestCase {
HSSFCell c = null;
//get our minimum values
- r = s.createRow((short)1);
- c = r.createCell((short)1);
+ r = s.createRow(1);
+ c = r.createCell(1);
c.setCellFormula(1 + "+" + 1);
wb.write(out);
@@ -64,8 +64,8 @@ public final class TestFormulas extends TestCase {
FileInputStream in = new FileInputStream(file);
wb = new HSSFWorkbook(in);
s = wb.getSheetAt(0);
- r = s.getRow((short)1);
- c = r.getCell((short)1);
+ r = s.getRow(1);
+ c = r.getCell(1);
assertTrue("Formula is as expected",("1+1".equals(c.getCellFormula())));
in.close();
@@ -176,24 +176,24 @@ public final class TestFormulas extends TestCase {
//get our minimum values
- r = s.createRow((short)0);
- c = r.createCell((short)1);
+ r = s.createRow(0);
+ c = r.createCell(1);
c.setCellFormula(""+Float.MIN_VALUE + operator + Float.MIN_VALUE);
for (short x = 1; x < Short.MAX_VALUE && x > 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<A2,B1,B2)");
+ r = s.createRow(0);
+ c=r.createCell(1); c.setCellFormula("IF(A1<A2,B1,B2)");
wb.write(out);
@@ -820,7 +820,7 @@ public final class TestFormulas extends TestCase {
wb = new HSSFWorkbook(in);
s = wb.getSheetAt(0);
r = s.getRow(0);
- c = r.getCell((short)1);
+ c = r.getCell(1);
assertEquals("Formula in cell 1 ","IF(A1<A2,B1,B2)",c.getCellFormula());
in.close();
}
@@ -835,8 +835,8 @@ public final class TestFormulas extends TestCase {
HSSFRow r = null;
HSSFCell c = null;
- r = s.createRow( (short)0 );
- c = r.createCell( (short)0 );
+ r = s.createRow(0 );
+ c = r.createCell(0 );
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
@@ -847,8 +847,8 @@ public final class TestFormulas extends TestCase {
// HSSFDateUtil.getJavaDate(excelDate).getTime());
for (int k=1; k < 100; k++) {
- r=s.createRow((short)k);
- c=r.createCell((short)0);
+ r=s.createRow(k);
+ c=r.createCell(0);
c.setCellFormula("A"+(k)+"+1");
c.setCellStyle(cellStyle);
}
@@ -870,11 +870,11 @@ public final class TestFormulas extends TestCase {
HSSFSheet s = wb.createSheet("testSheet1");
HSSFRow r = null;
HSSFCell c = null;
- r = s.createRow((short)0);
- c=r.createCell((short)1); c.setCellValue(1);
- c=r.createCell((short)2); c.setCellValue(2);
- c=r.createCell((short)3); c.setCellFormula("MAX(A1:B1)");
- c=r.createCell((short)4); c.setCellFormula("IF(A1=D1,\"A1\",\"B1\")");
+ r = s.createRow(0);
+ c=r.createCell(1); c.setCellValue(1);
+ c=r.createCell(2); c.setCellValue(2);
+ c=r.createCell(3); c.setCellFormula("MAX(A1:B1)");
+ c=r.createCell(4); c.setCellFormula("IF(A1=D1,\"A1\",\"B1\")");
wb.write(out);
out.close();
@@ -885,7 +885,7 @@ public final class TestFormulas extends TestCase {
wb = new HSSFWorkbook(in);
s = wb.getSheetAt(0);
r = s.getRow(0);
- c = r.getCell((short)4);
+ c = r.getCell(4);
assertTrue("expected: IF(A1=D1,\"A1\",\"B1\") got "+c.getCellFormula(), ("IF(A1=D1,\"A1\",\"B1\")").equals(c.getCellFormula()));
in.close();
@@ -893,7 +893,7 @@ public final class TestFormulas extends TestCase {
wb = openSample("IfFormulaTest.xls");
s = wb.getSheetAt(0);
r = s.getRow(3);
- c = r.getCell((short)0);
+ c = r.getCell(0);
assertTrue("expected: IF(A3=A1,\"A1\",\"A2\") got "+c.getCellFormula(), ("IF(A3=A1,\"A1\",\"A2\")").equals(c.getCellFormula()));
//c = r.getCell((short)1);
//assertTrue("expected: A!A1+A!B1 got: "+c.getCellFormula(), ("A!A1+A!B1").equals(c.getCellFormula()));
@@ -905,8 +905,8 @@ public final class TestFormulas extends TestCase {
s = wb.createSheet("testSheet1");
r = null;
c = null;
- r = s.createRow((short)0);
- c=r.createCell((short)0); c.setCellFormula("IF(1=1,0,1)");
+ r = s.createRow(0);
+ c=r.createCell(0); c.setCellFormula("IF(1=1,0,1)");
wb.write(out);
out.close();
@@ -920,21 +920,21 @@ public final class TestFormulas extends TestCase {
s = wb.createSheet("testSheet1");
r = null;
c = null;
- r = s.createRow((short)0);
- c=r.createCell((short)0);
+ r = s.createRow(0);
+ c=r.createCell(0);
c.setCellValue(1);
- c=r.createCell((short)1);
+ c=r.createCell(1);
c.setCellValue(3);
- HSSFCell formulaCell=r.createCell((short)3);
+ HSSFCell formulaCell=r.createCell(3);
- r = s.createRow((short)1);
- c=r.createCell((short)0);
+ r = s.createRow(1);
+ c=r.createCell(0);
c.setCellValue(3);
- c=r.createCell((short)1);
+ c=r.createCell(1);
c.setCellValue(7);
formulaCell.setCellFormula("IF(A1=B1,AVERAGE(A1:B1),AVERAGE(A2:B2))");
@@ -956,7 +956,7 @@ public final class TestFormulas extends TestCase {
HSSFSheet s = wb.getSheetAt(0);
HSSFRow r = s.getRow(0);
- HSSFCell c = r.getCell((short)2);
+ HSSFCell c = r.getCell(2);
assertEquals(function, c.getCellFormula());
@@ -965,29 +965,29 @@ public final class TestFormulas extends TestCase {
wb = new HSSFWorkbook();
s = wb.createSheet();
- r = s.createRow((short)0);
- c=r.createCell((short)0); c.setCellValue((double)1000);
- c=r.createCell((short)1); c.setCellValue((double)1);
+ r = s.createRow(0);
+ c=r.createCell(0); c.setCellValue((double)1000);
+ c=r.createCell(1); c.setCellValue((double)1);
- r = s.createRow((short)1);
- c=r.createCell((short)0); c.setCellValue((double)2000);
- c=r.createCell((short)1); c.setCellValue((double)2);
+ r = s.createRow(1);
+ c=r.createCell(0); c.setCellValue((double)2000);
+ c=r.createCell(1); c.setCellValue((double)2);
- r = s.createRow((short)2);
- c=r.createCell((short)0); c.setCellValue((double)3000);
- c=r.createCell((short)1); c.setCellValue((double)3);
+ r = s.createRow(2);
+ c=r.createCell(0); c.setCellValue((double)3000);
+ c=r.createCell(1); c.setCellValue((double)3);
- r = s.createRow((short)3);
- c=r.createCell((short)0); c.setCellValue((double)4000);
- c=r.createCell((short)1); c.setCellValue((double)4);
+ r = s.createRow(3);
+ c=r.createCell(0); c.setCellValue((double)4000);
+ c=r.createCell(1); c.setCellValue((double)4);
- r = s.createRow((short)4);
- c=r.createCell((short)0); c.setCellValue((double)5000);
- c=r.createCell((short)1); c.setCellValue((double)5);
+ r = s.createRow(4);
+ c=r.createCell(0); c.setCellValue((double)5000);
+ c=r.createCell(1); c.setCellValue((double)5);
r = s.getRow(0);
- c=r.createCell((short)2); c.setCellFormula(function);
+ c=r.createCell(2); c.setCellFormula(function);
wb.write(out);
out.close();
@@ -1002,42 +1002,42 @@ public final class TestFormulas extends TestCase {
HSSFSheet s0 = w.getSheetAt(0);
HSSFRow[] r = {s0.getRow(0), s0.getRow(1)};
- HSSFCell a1 = r[0].getCell((short) 0);
+ HSSFCell a1 = r[0].getCell(0);
assertEquals("square(1)", a1.getCellFormula());
assertEquals(1d, a1.getNumericCellValue(), 1e-9);
- HSSFCell a2 = r[1].getCell((short) 0);
+ HSSFCell a2 = r[1].getCell(0);
assertEquals("square(2)", a2.getCellFormula());
assertEquals(4d, a2.getNumericCellValue(), 1e-9);
- HSSFCell b1 = r[0].getCell((short) 1);
+ HSSFCell b1 = r[0].getCell(1);
assertEquals("IF(TRUE,square(1))", b1.getCellFormula());
assertEquals(1d, b1.getNumericCellValue(), 1e-9);
- HSSFCell b2 = r[1].getCell((short) 1);
+ HSSFCell b2 = r[1].getCell(1);
assertEquals("IF(TRUE,square(2))", b2.getCellFormula());
assertEquals(4d, b2.getNumericCellValue(), 1e-9);
- HSSFCell c1 = r[0].getCell((short) 2);
+ HSSFCell c1 = r[0].getCell(2);
assertEquals("square(square(1))", c1.getCellFormula());
assertEquals(1d, c1.getNumericCellValue(), 1e-9);
- HSSFCell c2 = r[1].getCell((short) 2);
+ HSSFCell c2 = r[1].getCell(2);
assertEquals("square(square(2))", c2.getCellFormula());
assertEquals(16d, c2.getNumericCellValue(), 1e-9);
- HSSFCell d1 = r[0].getCell((short) 3);
+ HSSFCell d1 = r[0].getCell(3);
assertEquals("square(one())", d1.getCellFormula());
assertEquals(1d, d1.getNumericCellValue(), 1e-9);
- HSSFCell d2 = r[1].getCell((short) 3);
+ HSSFCell d2 = r[1].getCell(3);
assertEquals("square(two())", d2.getCellFormula());
assertEquals(4d, d2.getNumericCellValue(), 1e-9);
}
public void testStringFormulaRead() {
HSSFWorkbook w = openSample("StringFormulas.xls");
- HSSFCell c = w.getSheetAt(0).getRow(0).getCell((short)0);
+ HSSFCell c = w.getSheetAt(0).getRow(0).getCell(0);
assertEquals("String Cell value","XYZ",c.getRichStringCellValue().getString());
}
@@ -1046,8 +1046,8 @@ public final class TestFormulas extends TestCase {
HSSFWorkbook sb = new HSSFWorkbook();
HSSFSheet s1 = sb.createSheet("Sheet a.1");
HSSFSheet s2 = sb.createSheet("Sheet.A");
- s2.createRow(1).createCell((short) 2).setCellFormula("'Sheet a.1'!A1");
- s1.createRow(1).createCell((short) 2).setCellFormula("'Sheet.A'!A1");
+ s2.createRow(1).createCell(2).setCellFormula("'Sheet a.1'!A1");
+ s1.createRow(1).createCell(2).setCellFormula("'Sheet.A'!A1");
File file = TempFile.createTempFile("testComplexSheetRefs",".xls");
sb.write(new FileOutputStream(file));
}
@@ -1073,17 +1073,17 @@ public final class TestFormulas extends TestCase {
/* MissingArgPtg */
public void testMissingArgPtg() throws Exception {
HSSFWorkbook wb = new HSSFWorkbook();
- HSSFCell cell = wb.createSheet("Sheet1").createRow(4).createCell((short) 0);
+ HSSFCell cell = wb.createSheet("Sheet1").createRow(4).createCell(0);
cell.setCellFormula("IF(A1=\"A\",1,)");
}
public void testSharedFormula() {
HSSFWorkbook wb = openSample("SharedFormulaTest.xls");
- assertEquals("A$1*2", wb.getSheetAt(0).getRow(1).getCell((short)1).toString());
- assertEquals("$A11*2", wb.getSheetAt(0).getRow(11).getCell((short)1).toString());
- assertEquals("DZ2*2", wb.getSheetAt(0).getRow(1).getCell((short)128).toString());
- assertEquals("B32770*2", wb.getSheetAt(0).getRow(32768).getCell((short)1).toString());
+ assertEquals("A$1*2", wb.getSheetAt(0).getRow(1).getCell(1).toString());
+ assertEquals("$A11*2", wb.getSheetAt(0).getRow(11).getCell(1).toString());
+ assertEquals("DZ2*2", wb.getSheetAt(0).getRow(1).getCell(128).toString());
+ assertEquals("B32770*2", wb.getSheetAt(0).getRow(32768).getCell(1).toString());
}
public static void main(String [] args) {
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
index da5d2cc6a9..30f63ab4a2 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
@@ -76,7 +76,7 @@ public final class TestHSSFCell extends TestCase {
HSSFSheet s = wb.createSheet("testSheet1");
HSSFRow r = null;
HSSFCell c = null;
- r = s.createRow((short)0);
+ r = s.createRow(0);
c=r.createCell(1);
//c.setCellType(HSSFCell.CELL_TYPE_BOOLEAN);
c.setCellValue(true);
@@ -85,7 +85,7 @@ public final class TestHSSFCell extends TestCase {
//c.setCellType(HSSFCell.CELL_TYPE_BOOLEAN);
c.setCellValue(false);
- r = s.createRow((short)1);
+ r = s.createRow(1);
c=r.createCell(1);
//c.setCellType(HSSFCell.CELL_TYPE_ERROR);
c.setCellErrorValue((byte)0);
@@ -241,7 +241,7 @@ public final class TestHSSFCell extends TestCase {
cs.setBorderLeft((short)1);
cs.setBorderBottom((short)1);
- r = s.createRow((short)0);
+ r = s.createRow(0);
c=r.createCell(0);
c.setCellStyle(cs);
c.setCellFormula("2*3");
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
index 978f435773..4ea0762dda 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
@@ -116,7 +116,7 @@ public final class TestHSSFComment extends TestCase {
for (int rownum = 0; rownum < 3; rownum++) {
row = sheet.getRow(rownum);
- cell = row.getCell((short)0);
+ cell = row.getCell(0);
comment = cell.getCellComment();
assertNull("Cells in the first column are not commented", comment);
assertNull(sheet.getCellComment(rownum, 0));
@@ -124,7 +124,7 @@ public final class TestHSSFComment extends TestCase {
for (int rownum = 0; rownum < 3; rownum++) {
row = sheet.getRow(rownum);
- cell = row.getCell((short)1);
+ cell = row.getCell(1);
comment = cell.getCellComment();
assertNotNull("Cells in the second column have comments", comment);
assertNotNull("Cells in the second column have comments", sheet.getCellComment(rownum, 1));
@@ -153,7 +153,7 @@ public final class TestHSSFComment extends TestCase {
for (int rownum = 0; rownum < 3; rownum++) {
row = sheet.getRow(rownum);
- cell = row.getCell((short)1);
+ cell = row.getCell(1);
comment = cell.getCellComment();
comment.setAuthor("Mofified["+rownum+"] by Yegor");
comment.setString(new HSSFRichTextString("Modified comment at row " + rownum));
@@ -168,7 +168,7 @@ public final class TestHSSFComment extends TestCase {
for (int rownum = 0; rownum < 3; rownum++) {
row = sheet.getRow(rownum);
- cell = row.getCell((short)1);
+ cell = row.getCell(1);
comment = cell.getCellComment();
assertEquals("Mofified["+rownum+"] by Yegor", comment.getAuthor());
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
index fcb0b8f41e..f9e62ffbf9 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.usermodel;
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator;
@@ -109,4 +110,44 @@ public final class TestHSSFConditionalFormatting extends TestCase
assertEquals("2",rule2.getFormula2());
assertEquals("1",rule2.getFormula1());
}
+
+ public void testClone() {
+
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sheet = wb.createSheet();
+ String formula = "7";
+
+ HSSFSheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
+
+ HSSFConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(formula);
+ HSSFFontFormatting fontFmt = rule1.createFontFormatting();
+ fontFmt.setFontStyle(true, false);
+
+ HSSFPatternFormatting patternFmt = rule1.createPatternFormatting();
+ patternFmt.setFillBackgroundColor(HSSFColor.YELLOW.index);
+
+
+ HSSFConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule(ComparisonOperator.BETWEEN, "1", "2");
+ HSSFConditionalFormattingRule [] cfRules =
+ {
+ rule1, rule2
+ };
+
+ short col = 1;
+ CellRangeAddress [] regions = {
+ new CellRangeAddress(0, 65535, col, col)
+ };
+
+ sheetCF.addConditionalFormatting(regions, cfRules);
+
+ try {
+ wb.cloneSheet(0);
+ } catch (RuntimeException e) {
+ if (e.getMessage().indexOf("needs to define a clone method") > 0) {
+ throw new AssertionFailedError("Indentified bug 45682");
+ }
+ throw e;
+ }
+ assertEquals(2, wb.getNumberOfSheets());
+ }
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
index 377a8ffe24..9e451ee052 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
@@ -16,7 +16,6 @@
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel;
import java.util.Calendar;
@@ -52,9 +51,7 @@ public final class TestHSSFDateUtil extends TestCase {
* Checks the date conversion functions in the HSSFDateUtil class.
*/
- public void testDateConversion()
- throws Exception
- {
+ public void testDateConversion() {
// Iteratating over the hours exposes any rounding issues.
for (int hour = 0; hour < 23; hour++)
@@ -131,7 +128,7 @@ public final class TestHSSFDateUtil extends TestCase {
for (int hour = 0; hour < 24; hour++, excelDate += oneHour) {
// Skip 02:00 CET as that is the Daylight change time
- // and Java converts it automatically to 03:00 CEST
+ // and Java converts it automatically to 03:00 CEST
if (hour == 2) {
continue;
}
@@ -186,7 +183,7 @@ public final class TestHSSFDateUtil extends TestCase {
HSSFDateUtil.getExcelDate(javaDate, false), oneMinute);
}
}
-
+
/**
* Tests that we deal with time-zones properly
*/
@@ -207,8 +204,7 @@ public final class TestHSSFDateUtil extends TestCase {
assertEquals("Checking timezone " + id, expected.getTime(), javaDate.getTime());
}
}
-
-
+
/**
* Tests that we correctly detect date formats as such
*/
@@ -220,7 +216,7 @@ public final class TestHSSFDateUtil extends TestCase {
assertTrue( HSSFDateUtil.isInternalDateFormat(builtins[i]) );
assertTrue( HSSFDateUtil.isADateFormat(builtins[i],formatStr) );
}
-
+
// Now try a few built-in non date formats
builtins = new short[] { 0x01, 0x02, 0x17, 0x1f, 0x30 };
for(int i=0; i<builtins.length; i++) {
@@ -228,14 +224,14 @@ public final class TestHSSFDateUtil extends TestCase {
assertFalse( HSSFDateUtil.isInternalDateFormat(builtins[i]) );
assertFalse( HSSFDateUtil.isADateFormat(builtins[i],formatStr) );
}
-
+
// Now for some non-internal ones
// These come after the real ones
int numBuiltins = HSSFDataFormat.getNumberOfBuiltinBuiltinFormats();
assertTrue(numBuiltins < 60);
short formatId = 60;
assertFalse( HSSFDateUtil.isInternalDateFormat(formatId) );
-
+
// Valid ones first
String[] formats = new String[] {
"yyyy-mm-dd", "yyyy/mm/dd", "yy/mm/dd", "yy/mmm/dd",
@@ -243,7 +239,7 @@ public final class TestHSSFDateUtil extends TestCase {
"dd-mm-yy", "dd-mm-yyyy",
"DD-MM-YY", "DD-mm-YYYY",
"dd\\-mm\\-yy", // Sometimes escaped
-
+
// These crazy ones are valid
"yyyy-mm-dd;@", "yyyy/mm/dd;@",
"dd-mm-yy;@", "dd-mm-yyyy;@",
@@ -257,14 +253,14 @@ public final class TestHSSFDateUtil extends TestCase {
};
for(int i=0; i<formats.length; i++) {
assertTrue(
- formats[i] + " is a date format",
- HSSFDateUtil.isADateFormat(formatId, formats[i])
+ formats[i] + " is a date format",
+ HSSFDateUtil.isADateFormat(formatId, formats[i])
);
}
-
+
// Then time based ones too
formats = new String[] {
- "yyyy-mm-dd hh:mm:ss", "yyyy/mm/dd HH:MM:SS",
+ "yyyy-mm-dd hh:mm:ss", "yyyy/mm/dd HH:MM:SS",
"mm/dd HH:MM", "yy/mmm/dd SS",
"mm/dd HH:MM AM", "mm/dd HH:MM am",
"mm/dd HH:MM PM", "mm/dd HH:MM pm",
@@ -272,30 +268,30 @@ public final class TestHSSFDateUtil extends TestCase {
};
for(int i=0; i<formats.length; i++) {
assertTrue(
- formats[i] + " is a datetime format",
- HSSFDateUtil.isADateFormat(formatId, formats[i])
+ formats[i] + " is a datetime format",
+ HSSFDateUtil.isADateFormat(formatId, formats[i])
);
}
-
+
// Then invalid ones
formats = new String[] {
- "yyyy*mm*dd",
+ "yyyy*mm*dd",
"0.0", "0.000",
"0%", "0.0%",
"[]Foo", "[BLACK]0.00%",
"", null
};
for(int i=0; i<formats.length; i++) {
- assertFalse(
- formats[i] + " is not a date or datetime format",
- HSSFDateUtil.isADateFormat(formatId, formats[i])
+ assertFalse(
+ formats[i] + " is not a date or datetime format",
+ HSSFDateUtil.isADateFormat(formatId, formats[i])
);
}
-
+
// And these are ones we probably shouldn't allow,
// but would need a better regexp
formats = new String[] {
- "yyyy:mm:dd",
+ "yyyy:mm:dd",
};
for(int i=0; i<formats.length; i++) {
// assertFalse( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
@@ -306,63 +302,63 @@ public final class TestHSSFDateUtil extends TestCase {
* Test that against a real, test file, we still do everything
* correctly
*/
- public void testOnARealFile() throws Exception {
+ public void testOnARealFile() {
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("DateFormats.xls");
HSSFSheet sheet = workbook.getSheetAt(0);
Workbook wb = workbook.getWorkbook();
-
+
HSSFRow row;
HSSFCell cell;
HSSFCellStyle style;
-
+
double aug_10_2007 = 39304.0;
-
+
// Should have dates in 2nd column
// All of them are the 10th of August
// 2 US dates, 3 UK dates
row = sheet.getRow(0);
- cell = row.getCell((short)1);
+ cell = row.getCell(1);
style = cell.getCellStyle();
assertEquals(aug_10_2007, cell.getNumericCellValue(), 0.0001);
assertEquals("d-mmm-yy", style.getDataFormatString());
assertTrue(HSSFDateUtil.isInternalDateFormat(style.getDataFormat()));
assertTrue(HSSFDateUtil.isADateFormat(style.getDataFormat(), style.getDataFormatString()));
assertTrue(HSSFDateUtil.isCellDateFormatted(cell));
-
+
row = sheet.getRow(1);
- cell = row.getCell((short)1);
+ cell = row.getCell(1);
style = cell.getCellStyle();
assertEquals(aug_10_2007, cell.getNumericCellValue(), 0.0001);
assertFalse(HSSFDateUtil.isInternalDateFormat(cell.getCellStyle().getDataFormat()));
assertTrue(HSSFDateUtil.isADateFormat(style.getDataFormat(), style.getDataFormatString()));
assertTrue(HSSFDateUtil.isCellDateFormatted(cell));
-
+
row = sheet.getRow(2);
- cell = row.getCell((short)1);
+ cell = row.getCell(1);
style = cell.getCellStyle();
assertEquals(aug_10_2007, cell.getNumericCellValue(), 0.0001);
assertTrue(HSSFDateUtil.isInternalDateFormat(cell.getCellStyle().getDataFormat()));
assertTrue(HSSFDateUtil.isADateFormat(style.getDataFormat(), style.getDataFormatString()));
assertTrue(HSSFDateUtil.isCellDateFormatted(cell));
-
+
row = sheet.getRow(3);
- cell = row.getCell((short)1);
+ cell = row.getCell(1);
style = cell.getCellStyle();
assertEquals(aug_10_2007, cell.getNumericCellValue(), 0.0001);
assertFalse(HSSFDateUtil.isInternalDateFormat(cell.getCellStyle().getDataFormat()));
assertTrue(HSSFDateUtil.isADateFormat(style.getDataFormat(), style.getDataFormatString()));
assertTrue(HSSFDateUtil.isCellDateFormatted(cell));
-
+
row = sheet.getRow(4);
- cell = row.getCell((short)1);
+ cell = row.getCell(1);
style = cell.getCellStyle();
assertEquals(aug_10_2007, cell.getNumericCellValue(), 0.0001);
assertFalse(HSSFDateUtil.isInternalDateFormat(cell.getCellStyle().getDataFormat()));
assertTrue(HSSFDateUtil.isADateFormat(style.getDataFormat(), style.getDataFormatString()));
assertTrue(HSSFDateUtil.isCellDateFormatted(cell));
}
-
+
public void testDateBug_2Excel() {
assertEquals(59.0, HSSFDateUtil.getExcelDate(createDate(1900, CALENDAR_FEBRUARY, 28), false), 0.00001);
assertEquals(61.0, HSSFDateUtil.getExcelDate(createDate(1900, CALENDAR_MARCH, 1), false), 0.00001);
@@ -372,41 +368,49 @@ public final class TestHSSFDateUtil extends TestCase {
assertEquals(37257.00, HSSFDateUtil.getExcelDate(createDate(2002, CALENDAR_JANUARY, 1), false), 0.00001);
assertEquals(38074.00, HSSFDateUtil.getExcelDate(createDate(2004, CALENDAR_MARCH, 28), false), 0.00001);
}
-
+
public void testDateBug_2Java() {
assertEquals(createDate(1900, CALENDAR_FEBRUARY, 28), HSSFDateUtil.getJavaDate(59.0, false));
assertEquals(createDate(1900, CALENDAR_MARCH, 1), HSSFDateUtil.getJavaDate(61.0, false));
-
+
assertEquals(createDate(2002, CALENDAR_FEBRUARY, 28), HSSFDateUtil.getJavaDate(37315.00, false));
assertEquals(createDate(2002, CALENDAR_MARCH, 1), HSSFDateUtil.getJavaDate(37316.00, false));
assertEquals(createDate(2002, CALENDAR_JANUARY, 1), HSSFDateUtil.getJavaDate(37257.00, false));
assertEquals(createDate(2004, CALENDAR_MARCH, 28), HSSFDateUtil.getJavaDate(38074.00, false));
}
-
+
public void testDate1904() {
assertEquals(createDate(1904, CALENDAR_JANUARY, 2), HSSFDateUtil.getJavaDate(1.0, true));
assertEquals(createDate(1904, CALENDAR_JANUARY, 1), HSSFDateUtil.getJavaDate(0.0, true));
assertEquals(0.0, HSSFDateUtil.getExcelDate(createDate(1904, CALENDAR_JANUARY, 1), true), 0.00001);
assertEquals(1.0, HSSFDateUtil.getExcelDate(createDate(1904, CALENDAR_JANUARY, 2), true), 0.00001);
-
+
assertEquals(createDate(1998, CALENDAR_JULY, 5), HSSFDateUtil.getJavaDate(35981, false));
assertEquals(createDate(1998, CALENDAR_JULY, 5), HSSFDateUtil.getJavaDate(34519, true));
-
+
assertEquals(35981.0, HSSFDateUtil.getExcelDate(createDate(1998, CALENDAR_JULY, 5), false), 0.00001);
assertEquals(34519.0, HSSFDateUtil.getExcelDate(createDate(1998, CALENDAR_JULY, 5), true), 0.00001);
}
-
+
/**
- * @param month zero based
+ * @param month zero based
* @param day one based
*/
private static Date createDate(int year, int month, int day) {
+ return createDate(year, month, day, 0, 0, 0);
+ }
+
+ /**
+ * @param month zero based
+ * @param day one based
+ */
+ private static Date createDate(int year, int month, int day, int hour, int minute, int second) {
Calendar c = new GregorianCalendar();
- c.set(year, month, day, 0, 0, 0);
+ c.set(year, month, day, hour, minute, second);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
-
+
/**
* Check if HSSFDateUtil.getAbsoluteDay works as advertised.
*/
@@ -420,16 +424,27 @@ public final class TestHSSFDateUtil extends TestCase {
}
public void testConvertTime() {
-
+
final double delta = 1E-7; // a couple of digits more accuracy than strictly required
assertEquals(0.5, HSSFDateUtil.convertTime("12:00"), delta);
assertEquals(2.0/3, HSSFDateUtil.convertTime("16:00"), delta);
assertEquals(0.0000116, HSSFDateUtil.convertTime("0:00:01"), delta);
assertEquals(0.7330440, HSSFDateUtil.convertTime("17:35:35"), delta);
}
-
+
public void testParseDate() {
assertEquals(createDate(2008, Calendar.AUGUST, 3), HSSFDateUtil.parseYYYYMMDDDate("2008/08/03"));
assertEquals(createDate(1994, Calendar.MAY, 1), HSSFDateUtil.parseYYYYMMDDDate("1994/05/01"));
}
+
+ /**
+ * Ensure that date values *with* a fractional portion get the right time of day
+ */
+ public void testConvertDateTime() {
+ // Excel day 30000 is date 18-Feb-1982
+ // 0.7 corresponds to time 16:48:00
+ Date actual = HSSFDateUtil.getJavaDate(30000.7);
+ Date expected = createDate(1982, 1, 18, 16, 48, 0);
+ assertEquals(expected, actual);
+ }
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java
index 15ec903b4d..071e265bd7 100755
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java
@@ -42,14 +42,14 @@ public final class TestHSSFHyperlink extends TestCase {
HSSFHyperlink link;
sheet = wb.getSheet("WebLinks");
- cell = sheet.getRow(4).getCell((short)0);
+ cell = sheet.getRow(4).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("POI", link.getLabel());
assertEquals("POI", cell.getRichStringCellValue().getString());
assertEquals("http://poi.apache.org/", link.getAddress());
- cell = sheet.getRow(8).getCell((short)0);
+ cell = sheet.getRow(8).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("HSSF", link.getLabel());
@@ -57,7 +57,7 @@ public final class TestHSSFHyperlink extends TestCase {
assertEquals("http://poi.apache.org/hssf/", link.getAddress());
sheet = wb.getSheet("Emails");
- cell = sheet.getRow(4).getCell((short)0);
+ cell = sheet.getRow(4).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("dev", link.getLabel());
@@ -65,7 +65,7 @@ public final class TestHSSFHyperlink extends TestCase {
assertEquals("mailto:dev@poi.apache.org", link.getAddress());
sheet = wb.getSheet("Internal");
- cell = sheet.getRow(4).getCell((short)0);
+ cell = sheet.getRow(4).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("Link To First Sheet", link.getLabel());
@@ -81,7 +81,7 @@ public final class TestHSSFHyperlink extends TestCase {
HSSFHyperlink link;
sheet = wb.getSheet("WebLinks");
- cell = sheet.getRow(4).getCell((short)0);
+ cell = sheet.getRow(4).getCell(0);
link = cell.getHyperlink();
//modify the link
link.setAddress("www.apache.org");
@@ -92,7 +92,7 @@ public final class TestHSSFHyperlink extends TestCase {
wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));
sheet = wb.getSheet("WebLinks");
- cell = sheet.getRow(4).getCell((short)0);
+ cell = sheet.getRow(4).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("www.apache.org", link.getAddress());
@@ -106,21 +106,21 @@ public final class TestHSSFHyperlink extends TestCase {
HSSFSheet sheet = wb.createSheet("Hyperlinks");
//URL
- cell = sheet.createRow(0).createCell((short)0);
+ cell = sheet.createRow(0).createCell(0);
cell.setCellValue("URL Link");
HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
link.setAddress("http://poi.apache.org/");
cell.setHyperlink(link);
//link to a file in the current directory
- cell = sheet.createRow(1).createCell((short)0);
+ cell = sheet.createRow(1).createCell(0);
cell.setCellValue("File Link");
link = new HSSFHyperlink(HSSFHyperlink.LINK_FILE);
link.setAddress("link1.xls");
cell.setHyperlink(link);
//e-mail link
- cell = sheet.createRow(2).createCell((short)0);
+ cell = sheet.createRow(2).createCell(0);
cell.setCellValue("Email Link");
link = new HSSFHyperlink(HSSFHyperlink.LINK_EMAIL);
//note, if subject contains white spaces, make sure they are url-encoded
@@ -131,9 +131,9 @@ public final class TestHSSFHyperlink extends TestCase {
//create a target sheet and cell
HSSFSheet sheet2 = wb.createSheet("Target Sheet");
- sheet2.createRow(0).createCell((short)0).setCellValue("Target Cell");
+ sheet2.createRow(0).createCell(0).setCellValue("Target Cell");
- cell = sheet.createRow(3).createCell((short)0);
+ cell = sheet.createRow(3).createCell(0);
cell.setCellValue("Worksheet Link");
link = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
link.setAddress("'Target Sheet'!A1");
@@ -145,22 +145,22 @@ public final class TestHSSFHyperlink extends TestCase {
wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));
sheet = wb.getSheet("Hyperlinks");
- cell = sheet.getRow(0).getCell((short)0);
+ cell = sheet.getRow(0).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("http://poi.apache.org/", link.getAddress());
- cell = sheet.getRow(1).getCell((short)0);
+ cell = sheet.getRow(1).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("link1.xls", link.getAddress());
- cell = sheet.getRow(2).getCell((short)0);
+ cell = sheet.getRow(2).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("mailto:poi@apache.org?subject=Hyperlinks", link.getAddress());
- cell = sheet.getRow(3).getCell((short)0);
+ cell = sheet.getRow(3).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("'Target Sheet'!A1", link.getAddress());
@@ -174,12 +174,12 @@ public final class TestHSSFHyperlink extends TestCase {
HSSFSheet sheet = wb.cloneSheet(0);
- cell = sheet.getRow(4).getCell((short)0);
+ cell = sheet.getRow(4).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("http://poi.apache.org/", link.getAddress());
- cell = sheet.getRow(8).getCell((short)0);
+ cell = sheet.getRow(8).getCell(0);
link = cell.getHyperlink();
assertNotNull(link);
assertEquals("http://poi.apache.org/hssf/", link.getAddress());
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
index b998fdd519..a3efa0393d 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
@@ -107,13 +107,13 @@ public class TestHSSFOptimiser extends TestCase {
HSSFRichTextString rtr1 = new HSSFRichTextString("Test");
rtr1.applyFont(0, 2, f1);
rtr1.applyFont(3, 4, f2);
- r.createCell((short)0).setCellValue(rtr1);
+ r.createCell(0).setCellValue(rtr1);
HSSFRichTextString rtr2 = new HSSFRichTextString("AlsoTest");
rtr2.applyFont(0, 2, f3);
rtr2.applyFont(3, 5, f5);
rtr2.applyFont(6, 8, f6);
- r.createCell((short)1).setCellValue(rtr2);
+ r.createCell(1).setCellValue(rtr2);
// Check what we have now
@@ -198,14 +198,14 @@ public class TestHSSFOptimiser extends TestCase {
HSSFSheet s = wb.createSheet();
HSSFRow r = s.createRow(0);
- r.createCell((short)0).setCellStyle(cs1);
- r.createCell((short)1).setCellStyle(cs2);
- r.createCell((short)2).setCellStyle(cs3);
- r.createCell((short)3).setCellStyle(cs4);
- r.createCell((short)4).setCellStyle(cs5);
- r.createCell((short)5).setCellStyle(cs6);
- r.createCell((short)6).setCellStyle(cs1);
- r.createCell((short)7).setCellStyle(cs2);
+ r.createCell(0).setCellStyle(cs1);
+ r.createCell(1).setCellStyle(cs2);
+ r.createCell(2).setCellStyle(cs3);
+ r.createCell(3).setCellStyle(cs4);
+ r.createCell(4).setCellStyle(cs5);
+ r.createCell(5).setCellStyle(cs6);
+ r.createCell(6).setCellStyle(cs1);
+ r.createCell(7).setCellStyle(cs2);
assertEquals(21, r.getCell(0).getCellValueRecord().getXFIndex());
assertEquals(26, r.getCell(5).getCellValueRecord().getXFIndex());
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java
index c3c0ed2259..3ce255a0e4 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java
@@ -94,11 +94,11 @@ public final class TestHSSFPalette extends TestCase {
HSSFPalette p = book.getCustomPalette();
- HSSFCell cellA = book.getSheetAt(0).getRow(0).getCell((short)0);
- HSSFCell cellB = book.getSheetAt(0).getRow(1).getCell((short)0);
- HSSFCell cellC = book.getSheetAt(0).getRow(2).getCell((short)0);
- HSSFCell cellD = book.getSheetAt(0).getRow(3).getCell((short)0);
- HSSFCell cellE = book.getSheetAt(0).getRow(4).getCell((short)0);
+ HSSFCell cellA = book.getSheetAt(0).getRow(0).getCell(0);
+ HSSFCell cellB = book.getSheetAt(0).getRow(1).getCell(0);
+ HSSFCell cellC = book.getSheetAt(0).getRow(2).getCell(0);
+ HSSFCell cellD = book.getSheetAt(0).getRow(3).getCell(0);
+ HSSFCell cellE = book.getSheetAt(0).getRow(4).getCell(0);
// Plain
assertEquals("I'm plain", cellA.getStringCellValue());
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java
index b09753bcbd..c9b3bc74d1 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java
@@ -36,16 +36,16 @@ public final class TestHSSFRow extends TestCase {
assertEquals(-1, row.getFirstCellNum());
assertEquals(-1, row.getLastCellNum());
- row.createCell((short) 2);
+ row.createCell(2);
assertEquals(2, row.getFirstCellNum());
assertEquals(3, row.getLastCellNum());
- row.createCell((short) 1);
+ row.createCell(1);
assertEquals(1, row.getFirstCellNum());
assertEquals(3, row.getLastCellNum());
// check the exact case reported in 'bug' 43901 - notice that the cellNum is '0' based
- row.createCell((short) 3);
+ row.createCell(3);
assertEquals(1, row.getFirstCellNum());
assertEquals(4, row.getLastCellNum());
}
@@ -59,20 +59,20 @@ public final class TestHSSFRow extends TestCase {
HSSFSheet sheet = workbook.createSheet();
HSSFRow rowA = sheet.createRow(0);
- rowA.createCell((short) 10);
- rowA.createCell((short) 5);
+ rowA.createCell(10);
+ rowA.createCell(5);
assertEquals(5, rowA.getFirstCellNum());
assertEquals(11, rowA.getLastCellNum());
HSSFRow rowB = sheet.createRow(1);
- rowB.createCell((short) 15);
- rowB.createCell((short) 30);
+ rowB.createCell(15);
+ rowB.createCell(30);
assertEquals(15, rowB.getFirstCellNum());
assertEquals(31, rowB.getLastCellNum());
assertEquals(5, rowA.getFirstCellNum());
assertEquals(11, rowA.getLastCellNum());
- rowA.createCell((short) 50);
+ rowA.createCell(50);
assertEquals(51, rowA.getLastCellNum());
assertEquals(31, rowB.getLastCellNum());
@@ -81,19 +81,19 @@ public final class TestHSSFRow extends TestCase {
public void testRemoveCell() {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
- HSSFRow row = sheet.createRow((short) 0);
+ HSSFRow row = sheet.createRow(0);
assertEquals(-1, row.getLastCellNum());
assertEquals(-1, row.getFirstCellNum());
- row.createCell((short) 1);
+ row.createCell(1);
assertEquals(2, row.getLastCellNum());
assertEquals(1, row.getFirstCellNum());
- row.createCell((short) 3);
+ row.createCell(3);
assertEquals(4, row.getLastCellNum());
assertEquals(1, row.getFirstCellNum());
- row.removeCell(row.getCell((short) 3));
+ row.removeCell(row.getCell(3));
assertEquals(2, row.getLastCellNum());
assertEquals(1, row.getFirstCellNum());
- row.removeCell(row.getCell((short) 1));
+ row.removeCell(row.getCell(1));
assertEquals(-1, row.getLastCellNum());
assertEquals(-1, row.getFirstCellNum());
@@ -114,18 +114,18 @@ public final class TestHSSFRow extends TestCase {
public void testMoveCell() {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
- HSSFRow row = sheet.createRow((short) 0);
- HSSFRow rowB = sheet.createRow((short) 1);
+ HSSFRow row = sheet.createRow(0);
+ HSSFRow rowB = sheet.createRow(1);
- HSSFCell cellA2 = rowB.createCell((short)0);
+ HSSFCell cellA2 = rowB.createCell(0);
assertEquals(0, rowB.getFirstCellNum());
assertEquals(0, rowB.getFirstCellNum());
assertEquals(-1, row.getLastCellNum());
assertEquals(-1, row.getFirstCellNum());
- HSSFCell cellB2 = row.createCell((short) 1);
- HSSFCell cellB3 = row.createCell((short) 2);
- HSSFCell cellB4 = row.createCell((short) 3);
+ HSSFCell cellB2 = row.createCell(1);
+ HSSFCell cellB3 = row.createCell(2);
+ HSSFCell cellB4 = row.createCell(3);
assertEquals(1, row.getFirstCellNum());
assertEquals(4, row.getLastCellNum());
@@ -147,10 +147,10 @@ public final class TestHSSFRow extends TestCase {
}
// Move somewhere spare
- assertNotNull(row.getCell((short)1));
+ assertNotNull(row.getCell(1));
row.moveCell(cellB2, (short)5);
- assertNull(row.getCell((short)1));
- assertNotNull(row.getCell((short)5));
+ assertNull(row.getCell(1));
+ assertNotNull(row.getCell(5));
assertEquals(5, cellB2.getCellNum());
assertEquals(2, row.getFirstCellNum());
@@ -161,7 +161,7 @@ public final class TestHSSFRow extends TestCase {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
//Test low row bound
- sheet.createRow( (short) 0);
+ sheet.createRow(0);
//Test low row bound exception
try {
sheet.createRow(-1);
@@ -200,9 +200,9 @@ public final class TestHSSFRow extends TestCase {
// Create two cells, will return one higher
// than that for the last number
- row.createCell((short) 0);
+ row.createCell(0);
assertEquals(1, row.getLastCellNum());
- row.createCell((short) 255);
+ row.createCell(255);
assertEquals(256, row.getLastCellNum());
}
@@ -220,10 +220,10 @@ public final class TestHSSFRow extends TestCase {
// 3 missing
// 4 -> 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 a24e5e7970..4c8c8c5d6a 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
@@ -147,10 +147,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);
@@ -164,7 +164,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);
}
@@ -186,8 +186,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)");
@@ -216,8 +216,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);
@@ -510,11 +510,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);
@@ -617,13 +617,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 */
@@ -633,7 +633,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());
}
@@ -710,8 +710,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 c0231cdfea..c6fa2ee0d9 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
@@ -96,7 +96,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"));
}
}
@@ -142,7 +142,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"));
}
}
@@ -226,8 +226,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);
@@ -239,7 +239,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);
@@ -350,7 +350,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));
}
@@ -360,7 +360,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());
}
@@ -439,7 +439,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"));
}
}
@@ -530,7 +530,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);
@@ -556,7 +556,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"));