@Override public HSSFCreationHelper getCreationHelper() { return new HSSFCreationHelper(this); }
newStyle.setVerticalAlignment(cellStyle.getVerticalAlignmentEnum()); DataFormat dataFormat = resultWorkbook.getCreationHelper().createDataFormat(); newStyle.setDataFormat(dataFormat.getFormat(cellStyle.getDataFormatString())); newStyle.setHidden(cellStyle.getHidden());
private void writeHeaders(HSSFSheet sheet, String title, List<XlsColumn> columns) { Cell titleCell = sheet.createRow(0).createCell(0); titleCell.setCellValue(book.getCreationHelper().createRichTextString(title)); titleCell.setCellStyle(titleStyle); Row columnHeaderRow = sheet.createRow(1); columnHeaderRow.setHeightInPoints(HEADER_CELL_HEIGHT); int columnIndex = 0; for (int i = 0; i < columns.size(); i++) { XlsColumn column = columns.get(i); Cell cell = columnHeaderRow.createCell(columnIndex); cell.setCellStyle(headerStyle); cell.setCellValue(column.getHeading()); sheet.setColumnWidth(columnIndex, width(column.getHeading())); columnIndex++; } }
/** * Evaluate if the cell contains the formula * * @param workbook the workbook that contains the cell * @param cell the cell that contains the formula * @return the object representation of formula cell value. */ private Object evaluateCellFormula(final HSSFWorkbook workbook, final Cell cell) { FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); CellValue cellValue = evaluator.evaluate(cell); Object result = null; if (cellValue.getCellType() == Cell.CELL_TYPE_BOOLEAN) { result = cellValue.getBooleanValue(); } else if (cellValue.getCellType() == Cell.CELL_TYPE_NUMERIC) { result = cellValue.getNumberValue(); } else if (cellValue.getCellType() == Cell.CELL_TYPE_STRING) { result = cellValue.getStringValue(); } return result; }
HSSFHyperlink link = helper.createHyperlink(HyperlinkType.URL); link.setAddress("http://poi.apache.org/"); cell.setHyperlink(link); link = helper.createHyperlink(HyperlinkType.FILE); link.setAddress("link1.xls"); cell.setHyperlink(link); link = helper.createHyperlink(HyperlinkType.EMAIL); link = helper.createHyperlink(HyperlinkType.DOCUMENT); link.setAddress("'Target Sheet'!A1"); cell.setHyperlink(link);
newStyle.setVerticalAlignment(cellStyle.getVerticalAlignment()); DataFormat dataFormat = resultWorkbook.getCreationHelper().createDataFormat(); newStyle.setDataFormat(dataFormat.getFormat(cellStyle.getDataFormatString())); newStyle.setHidden(cellStyle.getHidden());
@Override public HSSFCreationHelper getCreationHelper() { return new HSSFCreationHelper(this); }
public HSSFCreationHelper getCreationHelper() { return new HSSFCreationHelper(this); }
public HSSFCreationHelper getCreationHelper() { return new HSSFCreationHelper(this); }