protected XSSFCell nextCell(XSSFCellStyle cellStyle) { currentColumnNumber++; XSSFCell cell = currentRow.createCell(currentColumnNumber); cell.setCellStyle(cellStyle); return cell; }
XSSFDataFormat df = workBook.createDataFormat(); cs.setDataFormat(df.getFormat("d-mmm-yy")); // Get / Create our cell XSSFRow row = sheet.createRow(2); XSSFCell cell = row.createCell(3); // Set it to be a date Calendar c = Calendar.getInstance(); c.set(2012,3-1,18); // Don't forget months are 0 based on Calendar cell.setCellValue( c.getTime() ); // Style it as a date cell.setCellStyle(cs);
protected XSSFCell nextCellVertically(XSSFCellStyle cellStyle) { currentRowNumber++; currentRow = currentSheet.getRow(currentRowNumber); XSSFCell cell = currentRow.createCell(currentColumnNumber); cell.setCellStyle(cellStyle); return cell; }
if (cell != null) { cell.setCellType(CellType.BLANK); cell.setCellStyle(null);
setCellStyle(srcCell == null ? null : srcCell.getCellStyle());
XSSFCell newCell = row.createCell(0); newCell.setCellStyle(myStyle);
protected XSSFCell nextCell(XSSFCellStyle cellStyle) { currentColumnNumber++; XSSFCell cell = currentRow.createCell(currentColumnNumber); cell.setCellStyle(cellStyle); return cell; }
XSSFCellStyle textFormatStyle = book.createCellStyle(); textFormatStyle.setDataFormat((short)BuiltinFormats.getBuiltinFormat("text")); XSSFCell cell = row.createCell(columnIndex++); cell.setCellStyle(textFormatStyle);
XSSFRow myRow = (XSSFRow) rowIter.next(); Iterator cellIter = myRow.cellIterator(); List cellRowList = new ArrayList(); while (cellIter.hasNext()) { XSSFCell originalCell = (XSSFCell) cellIter.next(); XSSFCell myCell = originalCell; try { // XSSFCell newCell = myCell; //( How to clone or copy a new one) XSSFCellStyle style = workbook.createCellStyle(); // the XSSFWorkbook from which you clone style.cloneStyleFrom(originalCell.getCellStyle()); myCell.setCellStyle(style); } catch (Exception e) { syso(e); } }
@Override public void setWritableCell(TableModel tableModel, XSSFCell cell, Object value, int row, int col) { LocalDate localDate = (LocalDate) value; cell.setCellStyle(cellStyle); if (localDate != null) { cell.setCellValue(localDate.toDate()); } } }
@Override public void setWritableCell(TableModel tableModel, XSSFCell cell, Object value, int row, int col) { LocalDateTime localDateTime = (LocalDateTime) value; cell.setCellStyle(cellStyle); if (localDateTime != null) { cell.setCellValue(localDateTime.toDate()); } } }
protected XSSFCell nextCellVertically(XSSFCellStyle cellStyle) { currentRowNumber++; currentRow = currentSheet.getRow(currentRowNumber); XSSFCell cell = currentRow.createCell(currentColumnNumber); cell.setCellStyle(cellStyle); return cell; }
for(i=0;i<rowsize;i++){ // //I suppose that we have an instance named row to working on. // XSSFCell cell = row.getCell(i); XSSFCellStyle style1 = wb.createCellStyle(); //create a fresh instance cell.setCellValue("custom XSSF colors"); //Set the cell value //This two line will setup the style of your cell with your needs style1.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128))); style1.setFillPattern(CellStyle.SOLID_FOREGROUND); //Finally apply your style cell.setCellStyle(style1); }
private static XSSFRow createHeaderRow(XSSFWorkbook wb, XSSFSheet sheet, Set columnSet){ CellStyle headerCellStyle = getHeaderCellStyle(wb); XSSFRow headerRow = sheet.createRow(0); headerRow.setHeight((short) 300); // Row Height int headerCellIndex = 0; for(Object columnName : columnSet){ // Column XSSFCell cell = headerRow.createCell((short) headerCellIndex); cell.setCellValue(columnName.toString()); cell.setCellStyle(headerCellStyle); headerCellIndex++; } return headerRow; }
private void createHeaderCell(MaintenanceEventsElementsReportEnum e, XSSFRow headerLine, XSSFCellStyle style, Locale locale) { XSSFCell headerCell = headerLine.createCell(e.getPosition()); headerCell.setCellValue(e.getLabel(translationService, locale)); headerCell.setCellStyle(style); }
@Override public void setWritableCell(TableModel tableModel, XSSFCell cell, Object value, int row, int col) { XSSFWorkbook wb = cell.getSheet().getWorkbook(); cell.setCellStyle(cellStyle); cell.setCellValue(wb.getCreationHelper().createRichTextString(value.toString())); cell.setCellType(XSSFCell.CELL_TYPE_STRING); } }
@Override public void setWritableCell(TableModel tableModel, XSSFCell cell, Object value, int row, int col) { XSSFWorkbook wb = cell.getSheet().getWorkbook(); cell.setCellStyle(cellStyle); cell.setCellValue(wb.getCreationHelper().createRichTextString(getString(tableModel, value, row, col))); cell.setCellType(XSSFCell.CELL_TYPE_STRING); }
@Override public void setWritableCell(TableModel tableModel, XSSFCell cell, Object value, int row, int col) { String string = getString((LocalTime) value); XSSFWorkbook wb = cell.getSheet().getWorkbook(); cell.setCellStyle(cellStyle); cell.setCellType(XSSFCell.CELL_TYPE_STRING); if (string != null) { cell.setCellValue(wb.getCreationHelper().createRichTextString(string)); } }
public static void hyperlinkScreenshot(XSSFCell cell, String FileAddress){ XSSFWorkbook wb=cell.getRow().getSheet().getWorkbook(); CreationHelper createHelper = wb.getCreationHelper(); CellStyle hlink_style = wb.createCellStyle(); Font hlink_font = wb.createFont(); hlink_font.setUnderline(Font.U_SINGLE); hlink_font.setColor(IndexedColors.BLUE.getIndex()); hlink_style.setFont(hlink_font); Hyperlink hp = createHelper.createHyperlink(Hyperlink.LINK_FILE); FileAddress=FileAddress.replace("\\", "/"); hp.setAddress(FileAddress); cell.setHyperlink(hp); cell.setCellStyle(hlink_style); }
private static void appendNotesRow(XSSFWorkbook wb, XSSFSheet sheet, int rowNum, String app, double effort, String notes) { 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); }