List of usage examples for org.apache.poi.xssf.usermodel XSSFCell setCellStyle
@Override public void setCellStyle(CellStyle style)
Set the style for the cell.
From source file:org.jboss.windup.reporting.spreadsheet.ScorecardReporter.java
License:Open Source License
private static void appendMentoringTitleRow(XSSFWorkbook wb, XSSFSheet sheet, int rowNum) { XSSFCellStyle titleCell = wb.createCellStyle(); Color titleCellGrey = new Color(0xECECEC); XSSFColor color = new XSSFColor(titleCellGrey); titleCell.setFillForegroundColor(color); titleCell.setBorderBottom(CellStyle.BORDER_MEDIUM); titleCell.setBorderTop(CellStyle.BORDER_MEDIUM); titleCell.setFillPattern(CellStyle.SOLID_FOREGROUND); Font titleFormat = wb.createFont(); titleFormat.setBoldweight(Font.BOLDWEIGHT_BOLD); titleFormat.setColor((short) 0x0); titleCell.setFont(titleFormat);/*from w w w .java2 s. c om*/ XSSFRow row = sheet.createRow(rowNum); XSSFCell t1 = row.createCell(0); t1.setCellValue("Migration Service Estimate"); t1.setCellStyle(titleCell); XSSFCell t2 = row.createCell(1); t2.setCellStyle(titleCell); XSSFCell t3 = row.createCell(2); t3.setCellStyle(titleCell); XSSFCell t4 = row.createCell(3); t4.setCellStyle(titleCell); }
From source file:org.jboss.windup.reporting.spreadsheet.ScorecardReporter.java
License:Open Source License
private static void appendMentoringTotalRow(XSSFWorkbook wb, XSSFSheet sheet, int rowNum, int start, int end) { Font boldFont = wb.createFont(); boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD); boldFont.setColor((short) 0x0); XSSFCellStyle commentCell = wb.createCellStyle(); commentCell.setBorderTop(CellStyle.BORDER_THIN); XSSFCellStyle totalCell = wb.createCellStyle(); totalCell.setBorderTop(CellStyle.BORDER_THIN); totalCell.setFont(boldFont);/*from www . j a v a 2 s. com*/ XSSFCellStyle totalCellRight = wb.createCellStyle(); totalCellRight.setBorderTop(CellStyle.BORDER_THIN); totalCellRight.setAlignment(HorizontalAlignment.RIGHT); totalCellRight.setFont(boldFont); XSSFRow row = sheet.createRow(rowNum); XSSFCell t1 = row.createCell(0); t1.setCellValue("Total:"); t1.setCellStyle(totalCellRight); XSSFCell t2 = row.createCell(1); t2.setCellFormula("SUM(B" + start + ":B" + end + ")"); t2.setCellStyle(totalCell); XSSFCell t3 = row.createCell(2); t3.setCellStyle(totalCell); XSSFCell t4 = row.createCell(3); t4.setCellStyle(commentCell); }
From source file:org.jboss.windup.reporting.spreadsheet.ScorecardReporter.java
License:Open Source License
private static void appendNotesRow(XSSFWorkbook wb, XSSFSheet sheet, int rowNum, String app, double effort, String notes) {/*w ww .j av a 2 s . c o m*/ XSSFRow row = sheet.createRow(rowNum); XSSFCell t1 = row.createCell(0); t1.setCellValue(app); XSSFCell t2 = row.createCell(1); XSSFCellStyle t2s = wb.createCellStyle(); t2s.setAlignment(HorizontalAlignment.RIGHT); t2.setCellStyle(t2s); t2.setCellValue(effort); row.createCell(2); XSSFCell t4 = row.createCell(3); t4.setCellValue(notes); }
From source file:org.kopsox.spreadsheet.data.ooxml.OOXMLSheet.java
License:Open Source License
@Override public void setValueAt(int row, int column, Date value, String format) { XSSFRow excelRow = sheet.getRow(row); if (excelRow == null) { excelRow = sheet.createRow(row); }//from w ww .ja v a2 s . c o m XSSFCell excelCell = excelRow.getCell(column); if (excelCell == null) { excelCell = excelRow.createCell(column); } CreationHelper createHelper = this.sheet.getWorkbook().getCreationHelper(); CellStyle cellStyle = this.sheet.getWorkbook().createCellStyle(); cellStyle.setDataFormat(createHelper.createDataFormat().getFormat(format)); excelCell.setCellStyle(cellStyle); excelCell.setCellValue(value); excelCell.setCellType(Cell.CELL_TYPE_NUMERIC); }
From source file:org.kopsox.spreadsheet.data.ooxml.OOXMLSheet.java
License:Open Source License
@Override public void setValueAt(int row, int column, Time value, String format) { XSSFRow excelRow = sheet.getRow(row); if (excelRow == null) { excelRow = sheet.createRow(row); }/* w w w . ja v a 2 s . co m*/ XSSFCell excelCell = excelRow.getCell(column); if (excelCell == null) { excelCell = excelRow.createCell(column); } CreationHelper createHelper = this.sheet.getWorkbook().getCreationHelper(); CellStyle cellStyle = this.sheet.getWorkbook().createCellStyle(); cellStyle.setDataFormat(createHelper.createDataFormat().getFormat(format)); excelCell.setCellStyle(cellStyle); excelCell.setCellValue(value); excelCell.setCellType(Cell.CELL_TYPE_NUMERIC); }
From source file:org.kuali.test.runner.output.PoiHelper.java
License:Educational Community License
private void copyCell(XSSFCell oldCell, XSSFCell newCell, Map<Integer, XSSFCellStyle> styleMap) { if (styleMap != null) { int stHashCode = oldCell.getCellStyle().hashCode(); XSSFCellStyle newCellStyle = styleMap.get(stHashCode); if (newCellStyle == null) { newCellStyle = newCell.getSheet().getWorkbook().createCellStyle(); newCellStyle.cloneStyleFrom(oldCell.getCellStyle()); newCellStyle.setFont(oldCell.getCellStyle().getFont()); styleMap.put(stHashCode, newCellStyle); }//w w w . ja v a 2 s. c o m newCell.setCellStyle(newCellStyle); } switch (oldCell.getCellType()) { case XSSFCell.CELL_TYPE_STRING: newCell.setCellValue(oldCell.getStringCellValue()); break; case XSSFCell.CELL_TYPE_NUMERIC: newCell.setCellValue(oldCell.getNumericCellValue()); break; case XSSFCell.CELL_TYPE_BLANK: newCell.setCellType(HSSFCell.CELL_TYPE_BLANK); break; case XSSFCell.CELL_TYPE_BOOLEAN: newCell.setCellValue(oldCell.getBooleanCellValue()); break; case XSSFCell.CELL_TYPE_ERROR: newCell.setCellErrorValue(oldCell.getErrorCellValue()); break; case XSSFCell.CELL_TYPE_FORMULA: newCell.setCellFormula(oldCell.getCellFormula()); break; default: break; } }
From source file:org.obiba.mica.dataset.search.rest.harmonization.ExcelContingencyWriter.java
License:Open Source License
private <T extends Number> void writeTable(XSSFSheet sheet, List<List<T>> tmp, String title, List<String> headers, List<String> values, boolean isContinuous) { writeTableHeaders(sheet, title, headers); ArrayList<String> rowHeaders = Lists.newArrayList(values); if (!isContinuous) rowHeaders.add("Total"); int counter = 0; int rownum = 4; for (String k : rowHeaders) { int cellnum = 0; XSSFRow row = sheet.createRow(rownum++); XSSFCell cell = row.createCell(cellnum++); cell.setCellValue(k);// w w w . java 2 s. c o m cell.setCellStyle(headerStyle); for (T obj : tmp.get(counter)) { cell = row.createCell(cellnum++); cell.setCellStyle(tableStyle); if (obj instanceof Integer) cell.setCellValue((Integer) obj); else if (obj instanceof Float) cell.setCellValue((Float) obj); else cell.setCellValue(String.valueOf(obj)); } counter++; } sheet.autoSizeColumn(0); }
From source file:org.rapidpm.data.table.export.Table2XLSX.java
License:Apache License
@Override public ByteArrayOutputStream export(final Table table) { final XSSFWorkbook workbook = new XSSFWorkbook(); final XSSFSheet xssfSheet = workbook.createSheet(table.getTableName()); final Collection<ColumnInformation> infoList = table.getColumnInfoList(); final XSSFRow xssfHeaderRow = xssfSheet.createRow(0); for (final ColumnInformation information : infoList) { if (information.isExportable()) { final XSSFCell xssfCell = xssfHeaderRow.createCell(information.getSpaltenNr()); xssfCell.setCellValue(information.getSpaltenName()); xssfCell.setCellType(XSSFCell.CELL_TYPE_STRING); } else {// w w w . ja va 2s . com if (logger.isDebugEnabled()) { logger.debug("ColInfo not exportable " + information.getSpaltenName()); } } } final List<Row> tableRowList = table.getRowList(); for (final Row row : tableRowList) { final XSSFRow xssfRow = xssfSheet.createRow(row.getRowNr() + 1); final List<Cell> cellList = row.getCells(); for (final Cell cell : cellList) { if (cell.getColInfo().isExportable()) { final XSSFCell xssfCell = xssfRow.createCell(cell.getColInfo().getSpaltenNr()); final CellTypeEnum cellType = cell.getCellType(); if (cellType.equals(CellTypeEnum.RawData)) { xssfCell.setCellValue(cell.getFormattedValue()); xssfCell.setCellType(XSSFCell.CELL_TYPE_STRING); //JIRA MOD-32 CellType in Abhngigkeit der ValueClass z.B. Number } else if (cellType.equals(CellTypeEnum.RawLink)) { final XSSFCreationHelper helper = workbook.getCreationHelper(); final XSSFHyperlink xssfHyperlink = helper.createHyperlink(Hyperlink.LINK_URL); xssfHyperlink.setAddress(cell.getFormattedValue()); xssfHyperlink.setLabel(cell.getLabel()); xssfCell.setCellValue(cell.getLabel()); xssfCell.setHyperlink(xssfHyperlink); final CellStyle hlink_style = createHyperLinkStyle(workbook); xssfCell.setCellStyle(hlink_style); } else { } } else { if (logger.isDebugEnabled()) { logger.debug("Cell not exportable "); } } } } final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { workbook.write(outputStream); } catch (IOException e) { logger.error(e); } return outputStream; }
From source file:org.talend.mdm.webapp.browserecords.server.servlet.DownloadData.java
License:Open Source License
protected void fillHeader(XSSFRow row) { for (int i = 0; i < headerArray.length; i++) { XSSFCell cell = row.createCell((short) i); cell.setCellValue(headerArray[i]); cell.setCellStyle(cs); }/*from ww w. j a v a 2s . c om*/ }
From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase.java
License:Open Source License
/** * /*from w w w .j a v a 2 s. c o m*/ */ protected XSSFCell createHeaderCell(XSSFRow row, int index, String label) { XSSFCell cell = row.createCell(index); cell.setCellStyle(headerCellStyle); setCellValue(cell, label); return cell; }