use of org.apache.poi.ss.util.CellRangeAddress in project poi by apache.
the class BaseTestConditionalFormatting method testBug55380.
@Test
public void testBug55380() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
CellRangeAddress[] ranges = new CellRangeAddress[] { CellRangeAddress.valueOf("C9:D30"), CellRangeAddress.valueOf("C7:C31") };
ConditionalFormattingRule rule = sheet.getSheetConditionalFormatting().createConditionalFormattingRule("$A$1>0");
sheet.getSheetConditionalFormatting().addConditionalFormatting(ranges, rule);
wb.close();
}
use of org.apache.poi.ss.util.CellRangeAddress in project poi by apache.
the class TestCellWalk method testNotTraverseEmptyCells.
public void testNotTraverseEmptyCells() {
Workbook wb = new HSSFWorkbook();
Sheet sheet = new SheetBuilder(wb, testData).build();
CellRangeAddress range = CellRangeAddress.valueOf("A1:C3");
CellWalk cellWalk = new CellWalk(sheet, range);
countCellHandler.reset();
cellWalk.traverse(countCellHandler);
assertEquals(4, countCellHandler.getVisitedCellsNumber());
/* 1 + 2 + 5 + 9 */
assertEquals(17L, countCellHandler.getOrdinalNumberSum());
}
use of org.apache.poi.ss.util.CellRangeAddress in project poi by apache.
the class TestCellRange method testValueOf.
public void testValueOf() {
CellRangeAddress cr1 = CellRangeAddress.valueOf("A1:B1");
assertEquals(0, cr1.getFirstColumn());
assertEquals(0, cr1.getFirstRow());
assertEquals(1, cr1.getLastColumn());
assertEquals(0, cr1.getLastRow());
CellRangeAddress cr2 = CellRangeAddress.valueOf("B1");
assertEquals(1, cr2.getFirstColumn());
assertEquals(0, cr2.getFirstRow());
assertEquals(1, cr2.getLastColumn());
assertEquals(0, cr2.getLastRow());
}
use of org.apache.poi.ss.util.CellRangeAddress in project poi by apache.
the class TestBugs method test53564.
// As of POI 3.15 beta 2, LibreOffice does not display the diagonal border while it does display the bottom border
// I have not checked Excel to know if this is a LibreOffice or a POI problem.
@Test
public void test53564() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Page 1");
final short BLUE = 30;
HSSFSheetConditionalFormatting scf = sheet.getSheetConditionalFormatting();
HSSFConditionalFormattingRule rule = scf.createConditionalFormattingRule(ComparisonOperator.GT, "10");
HSSFBorderFormatting bord = rule.createBorderFormatting();
bord.setBorderDiagonal(BorderStyle.THICK);
assertEquals(BorderStyle.THICK, bord.getBorderDiagonalEnum());
bord.setBackwardDiagonalOn(true);
assertTrue(bord.isBackwardDiagonalOn());
bord.setForwardDiagonalOn(true);
assertTrue(bord.isForwardDiagonalOn());
bord.setDiagonalBorderColor(BLUE);
assertEquals(BLUE, bord.getDiagonalBorderColor());
// Create the bottom border style so we know what a border is supposed to look like
bord.setBorderBottom(BorderStyle.THICK);
assertEquals(BorderStyle.THICK, bord.getBorderBottomEnum());
bord.setBottomBorderColor(BLUE);
assertEquals(BLUE, bord.getBottomBorderColor());
CellRangeAddress[] A2_D4 = { new CellRangeAddress(1, 3, 0, 3) };
scf.addConditionalFormatting(A2_D4, rule);
// Set a cell value within the conditional formatting range whose rule would resolve to True.
Cell C3 = sheet.createRow(2).createCell(2);
C3.setCellValue(30.0);
// Manually check the output file with Excel to see if the diagonal border is present
//OutputStream fos = new FileOutputStream("/tmp/53564.xls");
//wb.write(fos);
//fos.close();
wb.close();
}
use of org.apache.poi.ss.util.CellRangeAddress in project poi by apache.
the class TestWorkbook method testRepeatingColsRowsMinusOne.
/**
* Test setRepeatingRowsAndColumns when startRow and startColumn are -1.
*/
@Test
public void testRepeatingColsRowsMinusOne() throws IOException {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Test Print Titles");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell(1);
cell.setCellValue(new HSSFRichTextString("hi"));
CellRangeAddress cra = new CellRangeAddress(-1, 1, -1, 1);
try {
sheet.setRepeatingColumns(cra);
fail("invalid start index is ignored");
} catch (IllegalArgumentException e) {
}
try {
sheet.setRepeatingRows(cra);
fail("invalid start index is ignored");
} catch (IllegalArgumentException e) {
}
sheet.setRepeatingColumns(null);
sheet.setRepeatingRows(null);
HSSFTestDataSamples.writeOutAndReadBack(workbook).close();
workbook.close();
}
Aggregations