use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class TestBugs method bug56450.
@Test
public void bug56450() throws Exception {
HSSFWorkbook wb = openSample("56450.xls");
HSSFSheet sheet = wb.getSheetAt(0);
int comments = 0;
for (Row r : sheet) {
for (Cell c : r) {
if (c.getCellComment() != null) {
assertNotNull(c.getCellComment().getString().getString());
comments++;
}
}
}
assertEquals(0, comments);
wb.close();
}
use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class TestBugs method test48703.
/**
* Sum across multiple workbooks
* eg =SUM($Sheet2.A1:$Sheet3.A1)
*/
@Test
public void test48703() throws Exception {
HSSFWorkbook wb = openSample("48703.xls");
assertEquals(3, wb.getNumberOfSheets());
// Check reading the formula
Sheet sheet = wb.getSheetAt(0);
Row r = sheet.getRow(0);
Cell c = r.getCell(0);
assertEquals("SUM(Sheet2:Sheet3!A1)", c.getCellFormula());
assertEquals(4.0, c.getNumericCellValue(), 0);
// Check the evaluated result
HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
eval.evaluateFormulaCellEnum(c);
assertEquals(4.0, c.getNumericCellValue(), 0);
wb.close();
}
use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class TestBugs method test55668.
@Test
public void test55668() throws IOException {
Workbook wb = HSSFTestDataSamples.openSampleWorkbook("55668.xls");
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals("IF(TRUE,\"\",\"\")", cell.getCellFormula());
assertEquals("", cell.getStringCellValue());
cell.setCellType(CellType.STRING);
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
try {
assertNull(cell.getCellFormula());
fail("Should throw an exception here");
} catch (IllegalStateException e) {
// expected here
}
assertEquals("", cell.getStringCellValue());
wb.close();
}
use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class TestUnfixedBugs method testFormulaRecordAggregate_1.
@Test
public void testFormulaRecordAggregate_1() throws Exception {
// fails at formula "=MEHRFACH.OPERATIONEN(E$3;$B$5;$D4)"
Workbook wb = HSSFTestDataSamples.openSampleWorkbook("44958_1.xls");
try {
for (int i = 0; i < wb.getNumberOfSheets(); i++) {
Sheet sheet = wb.getSheetAt(i);
assertNotNull(wb.getSheet(sheet.getSheetName()));
sheet.groupColumn((short) 4, (short) 5);
sheet.setColumnGroupCollapsed(4, true);
sheet.setColumnGroupCollapsed(4, false);
for (Row row : sheet) {
for (Cell cell : row) {
try {
cell.toString();
} catch (Exception e) {
throw new Exception("While handling: " + sheet.getSheetName() + "/" + row.getRowNum() + "/" + cell.getColumnIndex(), e);
}
}
}
}
} finally {
wb.close();
}
}
use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class TestUnfixedBugs method testBug57074.
@Test
public void testBug57074() throws IOException {
Workbook wb = HSSFTestDataSamples.openSampleWorkbook("57074.xls");
Sheet sheet = wb.getSheet("Sheet1");
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
HSSFColor bgColor = (HSSFColor) cell.getCellStyle().getFillBackgroundColorColor();
String bgColorStr = bgColor.getTriplet()[0] + ", " + bgColor.getTriplet()[1] + ", " + bgColor.getTriplet()[2];
//System.out.println(bgColorStr);
assertEquals("215, 228, 188", bgColorStr);
HSSFColor fontColor = (HSSFColor) cell.getCellStyle().getFillForegroundColorColor();
String fontColorStr = fontColor.getTriplet()[0] + ", " + fontColor.getTriplet()[1] + ", " + fontColor.getTriplet()[2];
//System.out.println(fontColorStr);
assertEquals("0, 128, 128", fontColorStr);
wb.close();
}
Aggregations