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
This commit is contained in:
Josh Micich 2008-08-25 22:41:08 +00:00
parent d4b6c06f2b
commit 04dfa8d39f
33 changed files with 337 additions and 337 deletions

View File

@ -113,7 +113,7 @@ public final class HSSFCellUtil
if ( cell == null )
{
cell = row.createCell( (short)column );
cell = row.createCell(column );
}
return cell;
}

View File

@ -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!!!!!");

View File

@ -109,7 +109,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor {
int firstCell = row.getFirstCellNum();
int lastCell = row.getLastCellNum();
for(int k=firstCell;k<lastCell;k++) {
HSSFCell cell = row.getCell((short)k);
HSSFCell cell = row.getCell(k);
boolean outputContents = false;
if(cell == null) { continue; }

View File

@ -343,7 +343,7 @@ public final class HSSFRow implements Comparable {
}
if(policy == CREATE_NULL_AS_BLANK) {
if(cell == null) {
return createCell((short)cellnum, HSSFCell.CELL_TYPE_BLANK);
return createCell(cellnum, HSSFCell.CELL_TYPE_BLANK);
}
return cell;
}

View File

@ -1817,7 +1817,7 @@ public final class HSSFSheet {
// new HSSFComment instances, which is bad
HSSFRow r = getRow(row);
if(r != null) {
HSSFCell c = r.getCell((short)column);
HSSFCell c = r.getCell(column);
if(c != null) {
return c.getCellComment();
} else {

View File

@ -139,7 +139,7 @@ public class TestModelFactory extends TestCase
ByteArrayOutputStream stream = new ByteArrayOutputStream();
HSSFSheet sheet = book.createSheet("Test");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell((short)0);
HSSFCell cell = row.createCell(0);
cell.setCellValue(10.5);
book.write(stream);
return stream;

View File

@ -365,8 +365,8 @@ public final class TestSSTRecord extends TestCase {
{
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("duprich1.xls");
HSSFSheet sheet = wb.getSheetAt( 1 );
assertEquals( "01/05 (Wed)", sheet.getRow( 0 ).getCell( (short) 8 ).getStringCellValue() );
assertEquals( "01/05 (Wed)", sheet.getRow( 1 ).getCell( (short) 8 ).getStringCellValue() );
assertEquals( "01/05 (Wed)", sheet.getRow( 0 ).getCell(8 ).getStringCellValue() );
assertEquals( "01/05 (Wed)", sheet.getRow( 1 ).getCell(8 ).getStringCellValue() );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
wb.write( baos );
@ -375,12 +375,12 @@ public final class TestSSTRecord extends TestCase {
wb = HSSFTestDataSamples.openSampleWorkbook("duprich2.xls");
sheet = wb.getSheetAt( 0 );
int row = 0;
assertEquals( "Testing", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
assertEquals( "rich", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
assertEquals( "text", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
assertEquals( "strings", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
assertEquals( "Testing", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
assertEquals( "Testing", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
assertEquals( "Testing", sheet.getRow( row++ ).getCell(0 ).getStringCellValue() );
assertEquals( "rich", sheet.getRow( row++ ).getCell(0 ).getStringCellValue() );
assertEquals( "text", sheet.getRow( row++ ).getCell(0 ).getStringCellValue() );
assertEquals( "strings", sheet.getRow( row++ ).getCell(0 ).getStringCellValue() );
assertEquals( "Testing", sheet.getRow( row++ ).getCell(0 ).getStringCellValue() );
assertEquals( "Testing", sheet.getRow( row++ ).getCell(0 ).getStringCellValue() );
wb.write( baos );
}

View File

@ -257,7 +257,7 @@ public class TestValueRecordsAggregate extends TestCase
}
}
private static String getFormulaFromFirstCell(HSSFSheet s, int rowIx) {
return s.getRow(rowIx).getCell((short)0).getCellFormula();
return s.getRow(rowIx).getCell(0).getCellFormula();
}
/**

View File

@ -34,7 +34,7 @@ public class TestAreaErrPtg extends AbstractPtgTestCase
{
HSSFWorkbook workbook = loadWorkbook("AreaErrPtg.xls");
assertEquals("Wrong formula string for area error", "SUM(#REF!)",
workbook.getSheetAt(0).getRow(0).getCell((short) 2).getCellFormula());
workbook.getSheetAt(0).getRow(0).getCell(2).getCellFormula());
}
}

View File

@ -103,7 +103,7 @@ public final class TestArrayPtg extends TestCase {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex42564-elementOrder.xls");
// The formula has an array with 3 rows and 5 columns
String formula = wb.getSheetAt(0).getRow(0).getCell((short)0).getCellFormula();
String formula = wb.getSheetAt(0).getRow(0).getCell(0).getCellFormula();
// TODO - These number literals should not have '.0'. Excel has different number rendering rules
if (formula.equals("SUM({1.0,6.0,11.0;2.0,7.0,12.0;3.0,8.0,13.0;4.0,9.0,14.0;5.0,10.0,15.0})")) {

View File

@ -34,7 +34,7 @@ public class TestErrPtg extends AbstractPtgTestCase
public void testReading() throws Exception
{
HSSFWorkbook workbook = loadWorkbook("ErrPtg.xls");
HSSFCell cell = workbook.getSheetAt(0).getRow(3).getCell((short) 0);
HSSFCell cell = workbook.getSheetAt(0).getRow(3).getCell(0);
assertEquals("Wrong cell value", 4.0, cell.getNumericCellValue(), 0.0);
assertEquals("Wrong cell formula", "ERROR.TYPE(#REF!)", cell.getCellFormula());
}

View File

@ -34,7 +34,7 @@ public class TestIntersectionPtg extends AbstractPtgTestCase
public void testReading() throws Exception
{
HSSFWorkbook workbook = loadWorkbook("IntersectionPtg.xls");
HSSFCell cell = workbook.getSheetAt(0).getRow(4).getCell((short) 2);
HSSFCell cell = workbook.getSheetAt(0).getRow(4).getCell(2);
assertEquals("Wrong cell value", 5.0, cell.getNumericCellValue(), 0.0);
assertEquals("Wrong cell formula", "SUM(A1:B2 B2:C3)", cell.getCellFormula());
}

View File

@ -37,11 +37,11 @@ public class TestPercentPtg extends AbstractPtgTestCase
HSSFSheet sheet = workbook.getSheetAt(0);
assertEquals("Wrong numeric value for original number", 53000.0,
sheet.getRow(0).getCell((short) 0).getNumericCellValue(), 0.0);
sheet.getRow(0).getCell(0).getNumericCellValue(), 0.0);
assertEquals("Wrong numeric value for percent formula result", 5300.0,
sheet.getRow(1).getCell((short) 0).getNumericCellValue(), 0.0);
sheet.getRow(1).getCell(0).getNumericCellValue(), 0.0);
assertEquals("Wrong formula string for percent formula", "A1*10%",
sheet.getRow(1).getCell((short) 0).getCellFormula());
sheet.getRow(1).getCell(0).getCellFormula());
}
}

View File

@ -34,7 +34,7 @@ public class TestRangePtg extends AbstractPtgTestCase
public void testReading() throws Exception
{
HSSFWorkbook workbook = loadWorkbook("RangePtg.xls");
HSSFCell cell = workbook.getSheetAt(0).getRow(3).getCell((short) 1);
HSSFCell cell = workbook.getSheetAt(0).getRow(3).getCell(1);
assertEquals("Wrong cell value", 10.0, cell.getNumericCellValue(), 0.0);
assertEquals("Wrong cell formula", "SUM(pineapple:B2)", cell.getCellFormula());
}

View File

@ -41,41 +41,41 @@ public final class TestReferencePtg extends TestCase {
// First row
assertEquals("Wrong numeric value for original number", 55.0,
sheet.getRow(0).getCell((short) 0).getNumericCellValue(), 0.0);
sheet.getRow(0).getCell(0).getNumericCellValue(), 0.0);
assertEquals("Wrong numeric value for referemce", 55.0,
sheet.getRow(0).getCell((short) 1).getNumericCellValue(), 0.0);
sheet.getRow(0).getCell(1).getNumericCellValue(), 0.0);
assertEquals("Wrong formula string for reference", "A1",
sheet.getRow(0).getCell((short) 1).getCellFormula());
sheet.getRow(0).getCell(1).getCellFormula());
// Now moving over the 2**15 boundary
// (Remember that excel row (n) is poi row (n-1)
assertEquals("Wrong numeric value for original number", 32767.0,
sheet.getRow(32766).getCell((short) 0).getNumericCellValue(), 0.0);
sheet.getRow(32766).getCell(0).getNumericCellValue(), 0.0);
assertEquals("Wrong numeric value for referemce", 32767.0,
sheet.getRow(32766).getCell((short) 1).getNumericCellValue(), 0.0);
sheet.getRow(32766).getCell(1).getNumericCellValue(), 0.0);
assertEquals("Wrong formula string for reference", "A32767",
sheet.getRow(32766).getCell((short) 1).getCellFormula());
sheet.getRow(32766).getCell(1).getCellFormula());
assertEquals("Wrong numeric value for original number", 32768.0,
sheet.getRow(32767).getCell((short) 0).getNumericCellValue(), 0.0);
sheet.getRow(32767).getCell(0).getNumericCellValue(), 0.0);
assertEquals("Wrong numeric value for referemce", 32768.0,
sheet.getRow(32767).getCell((short) 1).getNumericCellValue(), 0.0);
sheet.getRow(32767).getCell(1).getNumericCellValue(), 0.0);
assertEquals("Wrong formula string for reference", "A32768",
sheet.getRow(32767).getCell((short) 1).getCellFormula());
sheet.getRow(32767).getCell(1).getCellFormula());
assertEquals("Wrong numeric value for original number", 32769.0,
sheet.getRow(32768).getCell((short) 0).getNumericCellValue(), 0.0);
sheet.getRow(32768).getCell(0).getNumericCellValue(), 0.0);
assertEquals("Wrong numeric value for referemce", 32769.0,
sheet.getRow(32768).getCell((short) 1).getNumericCellValue(), 0.0);
sheet.getRow(32768).getCell(1).getNumericCellValue(), 0.0);
assertEquals("Wrong formula string for reference", "A32769",
sheet.getRow(32768).getCell((short) 1).getCellFormula());
sheet.getRow(32768).getCell(1).getCellFormula());
assertEquals("Wrong numeric value for original number", 32770.0,
sheet.getRow(32769).getCell((short) 0).getNumericCellValue(), 0.0);
sheet.getRow(32769).getCell(0).getNumericCellValue(), 0.0);
assertEquals("Wrong numeric value for referemce", 32770.0,
sheet.getRow(32769).getCell((short) 1).getNumericCellValue(), 0.0);
sheet.getRow(32769).getCell(1).getNumericCellValue(), 0.0);
assertEquals("Wrong formula string for reference", "A32770",
sheet.getRow(32769).getCell((short) 1).getCellFormula());
sheet.getRow(32769).getCell(1).getCellFormula());
}
public void testBug44921() {

View File

@ -34,7 +34,7 @@ public class TestUnionPtg extends AbstractPtgTestCase
public void testReading() throws Exception
{
HSSFWorkbook workbook = loadWorkbook("UnionPtg.xls");
HSSFCell cell = workbook.getSheetAt(0).getRow(4).getCell((short) 2);
HSSFCell cell = workbook.getSheetAt(0).getRow(4).getCell(2);
assertEquals("Wrong cell value", 24.0, cell.getNumericCellValue(), 0.0);
assertEquals("Wrong cell formula", "SUM(A1:B2,B2:C3)", cell.getCellFormula());
}

View File

@ -150,7 +150,7 @@ public final class TestReadMissingBuiltInFuncs extends TestCase {
// some other unexpected error
throw e;
}
String result = sheet.getRow(rowIx).getCell((short)0).getCellFormula();
String result = sheet.getRow(rowIx).getCell(0).getCellFormula();
if (false) {
System.err.println(result);
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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");

View File

@ -96,7 +96,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));
@ -104,7 +104,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));
@ -133,7 +133,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));
@ -148,7 +148,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());

View File

@ -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());

View File

@ -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());

View File

@ -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());

View File

@ -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());

View File

@ -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());

View File

@ -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");

View File

@ -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();

View File

@ -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());
}
/**

View File

@ -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());
}
}

View File

@ -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");
}

View File

@ -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"));