List of usage examples for org.apache.poi.xssf.usermodel XSSFCell setCellValue
@Override public void setCellValue(boolean value)
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 ww. ja v a 2s . co m*/ 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 ww w . j a v a 2 s .c o m 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) {//from w w w. ja va 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.jmesa.view.excel.Excel2007View.java
License:Apache License
@Override public Object render() { XSSFWorkbook workbook = new XSSFWorkbook(); Table table = this.getTable(); String caption = table.getCaption(); if (!StringUtils.hasText(caption)) { caption = "JMesa Export"; }/*from w w w . ja va2 s . c om*/ XSSFSheet sheet = workbook.createSheet(caption); Row row = table.getRow(); row.getRowRenderer(); List<Column> columns = table.getRow().getColumns(); // renderer header XSSFRow hssfRow = sheet.createRow(0); int columncount = 0; for (Column col : columns) { XSSFCell cell = hssfRow.createCell(columncount++); cell.setCellValue(new XSSFRichTextString(col.getTitle())); } // renderer body Collection<?> items = getCoreContext().getPageItems(); int rowcount = 1; for (Object item : items) { XSSFRow r = sheet.createRow(rowcount++); columncount = 0; for (Column col : columns) { XSSFCell cell = r.createCell(columncount++); Object value = col.getCellRenderer().render(item, rowcount); if (value == null) { value = ""; } if (value instanceof Number) { Double number = Double.valueOf(value.toString()); cell.setCellValue(number); } else { cell.setCellValue(new XSSFRichTextString(value.toString())); } } } return workbook; }
From source file:org.kopsox.spreadsheet.data.ooxml.OOXMLSheet.java
License:Open Source License
@Override public void setValueAt(int row, int column, String value) { XSSFRow excelRow = sheet.getRow(row); if (excelRow == null) { excelRow = sheet.createRow(row); }//from w w w .j a v a 2 s . c o m XSSFCell excelCell = excelRow.getCell(column); if (excelCell == null) { excelCell = excelRow.createCell(column); } XSSFRichTextString str = new XSSFRichTextString(value); excelCell.setCellValue(str); excelCell.setCellType(Cell.CELL_TYPE_STRING); }
From source file:org.kopsox.spreadsheet.data.ooxml.OOXMLSheet.java
License:Open Source License
@Override public void setValueAt(int row, int column, double value) { XSSFRow excelRow = sheet.getRow(row); if (excelRow == null) { excelRow = sheet.createRow(row); }/*from ww w .j av a 2s . co m*/ XSSFCell excelCell = excelRow.getCell(column); if (excelCell == null) { excelCell = excelRow.createCell(column); } 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, Date value, String format) { XSSFRow excelRow = sheet.getRow(row); if (excelRow == null) { excelRow = sheet.createRow(row); }/*w w w . j a 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, boolean value) { 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); } excelCell.setCellValue(value); excelCell.setCellType(Cell.CELL_TYPE_BOOLEAN); }
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); }/*from ww w.ja va2s .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.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 a2 s . c om 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; } }