use of org.apache.poi.ss.usermodel.CellStyle in project tdi-studio-se by Talend.
the class ExcelTool method getNormalCellStyle.
private CellStyle getNormalCellStyle() {
CellStyle preCellStyle = getPreCellStyle();
if (preCellStyle == null) {
if (cellStylesMapping.get("normal") != null) {
return cellStylesMapping.get("normal");
} else {
CellStyle style = wb.createCellStyle();
if (font != null) {
style.setFont(font);
}
cellStylesMapping.put("normal", style);
return style;
}
} else {
return preCellStyle;
}
}
use of org.apache.poi.ss.usermodel.CellStyle in project Robot-Scouter by SUPERCILEX.
the class SpreadsheetCache method createBaseStyle.
private CellStyle createBaseStyle() {
CellStyle style = mWorkbook.createCellStyle();
style.setWrapText(true);
return style;
}
use of org.apache.poi.ss.usermodel.CellStyle in project Robot-Scouter by SUPERCILEX.
the class SpreadsheetCache method createRowHeaderStyle.
private CellStyle createRowHeaderStyle() {
CellStyle rowHeaderStyle = createColumnHeaderStyle();
rowHeaderStyle.setAlignment(HorizontalAlignment.LEFT);
return rowHeaderStyle;
}
use of org.apache.poi.ss.usermodel.CellStyle in project poi by apache.
the class TestXSSFPropertyTemplate method clonePropertyTemplate.
@Test
public void clonePropertyTemplate() throws IOException {
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
PropertyTemplate pt = new PropertyTemplate();
pt.drawBorders(a1c3, BorderStyle.MEDIUM, IndexedColors.RED.getIndex(), BorderExtent.ALL);
PropertyTemplate pt2 = new PropertyTemplate(pt);
assertNotSame(pt2, pt);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
assertEquals(4, pt2.getNumBorderColors(i, j));
assertEquals(4, pt2.getNumBorderColors(i, j));
}
}
CellRangeAddress b2 = new CellRangeAddress(1, 1, 1, 1);
pt2.drawBorders(b2, BorderStyle.THIN, BorderExtent.ALL);
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet();
pt.applyBorders(sheet);
for (Row row : sheet) {
for (Cell cell : row) {
CellStyle cs = cell.getCellStyle();
assertEquals(BorderStyle.MEDIUM, cs.getBorderTopEnum());
assertEquals(BorderStyle.MEDIUM, cs.getBorderBottomEnum());
assertEquals(BorderStyle.MEDIUM, cs.getBorderLeftEnum());
assertEquals(BorderStyle.MEDIUM, cs.getBorderRightEnum());
assertEquals(IndexedColors.RED.getIndex(), cs.getTopBorderColor());
assertEquals(IndexedColors.RED.getIndex(), cs.getBottomBorderColor());
assertEquals(IndexedColors.RED.getIndex(), cs.getLeftBorderColor());
assertEquals(IndexedColors.RED.getIndex(), cs.getRightBorderColor());
}
}
wb.close();
}
use of org.apache.poi.ss.usermodel.CellStyle in project poi by apache.
the class TestXSSFPropertyTemplate method applyBorders.
@Test
public void applyBorders() throws IOException {
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
CellRangeAddress b2 = new CellRangeAddress(1, 1, 1, 1);
PropertyTemplate pt = new PropertyTemplate();
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet();
pt.drawBorders(a1c3, BorderStyle.THIN, IndexedColors.RED.getIndex(), BorderExtent.ALL);
pt.applyBorders(sheet);
for (Row row : sheet) {
for (Cell cell : row) {
CellStyle cs = cell.getCellStyle();
assertEquals(BorderStyle.THIN, cs.getBorderTopEnum());
assertEquals(IndexedColors.RED.getIndex(), cs.getTopBorderColor());
assertEquals(BorderStyle.THIN, cs.getBorderBottomEnum());
assertEquals(IndexedColors.RED.getIndex(), cs.getBottomBorderColor());
assertEquals(BorderStyle.THIN, cs.getBorderLeftEnum());
assertEquals(IndexedColors.RED.getIndex(), cs.getLeftBorderColor());
assertEquals(BorderStyle.THIN, cs.getBorderRightEnum());
assertEquals(IndexedColors.RED.getIndex(), cs.getRightBorderColor());
}
}
pt.drawBorders(b2, BorderStyle.NONE, BorderExtent.ALL);
pt.applyBorders(sheet);
for (Row row : sheet) {
for (Cell cell : row) {
CellStyle cs = cell.getCellStyle();
if (cell.getColumnIndex() != 1 || row.getRowNum() == 0) {
assertEquals(BorderStyle.THIN, cs.getBorderTopEnum());
assertEquals(IndexedColors.RED.getIndex(), cs.getTopBorderColor());
} else {
assertEquals(BorderStyle.NONE, cs.getBorderTopEnum());
}
if (cell.getColumnIndex() != 1 || row.getRowNum() == 2) {
assertEquals(BorderStyle.THIN, cs.getBorderBottomEnum());
assertEquals(IndexedColors.RED.getIndex(), cs.getBottomBorderColor());
} else {
assertEquals(BorderStyle.NONE, cs.getBorderBottomEnum());
}
if (cell.getColumnIndex() == 0 || row.getRowNum() != 1) {
assertEquals(BorderStyle.THIN, cs.getBorderLeftEnum());
assertEquals(IndexedColors.RED.getIndex(), cs.getLeftBorderColor());
} else {
assertEquals(BorderStyle.NONE, cs.getBorderLeftEnum());
}
if (cell.getColumnIndex() == 2 || row.getRowNum() != 1) {
assertEquals(BorderStyle.THIN, cs.getBorderRightEnum());
assertEquals(IndexedColors.RED.getIndex(), cs.getRightBorderColor());
} else {
assertEquals(BorderStyle.NONE, cs.getBorderRightEnum());
}
}
}
wb.close();
}
Aggregations