/** * @param cellFormat * @return this for chaining. */ public ExportCell setCellFormat(final String cellFormat) { this.cellFormat = new CellFormat(cellFormat); return this; }
@Override protected CellFormat clone() { final CellFormat clone = new CellFormat(); clone.alignment = this.alignment; clone.autoDatePrecision = this.autoDatePrecision; clone.dataFormat = this.dataFormat; clone.fillForegroundColor = this.fillForegroundColor; clone.font = this.font; clone.wrapText = this.wrapText; return clone; } }
public CellFormat ensureAndGetCellFormat() { if (cellFormat == null) { cellFormat = new CellFormat(); } return cellFormat; }
@Override public XlsContentProvider putFormat(final Object obj, final String dataFormat) { formatMap.put(obj, new CellFormat(dataFormat)); return this; }
public XlsContentProvider(final ExportContext exportContext, final ExportWorkbook workbook) { this.exportContext = exportContext; this.workbook = workbook; createFonts(); defaultFormatMap.put(Integer.class, new CellFormat("#,##0", CellStyle.ALIGN_RIGHT)); defaultFormatMap.put(Number.class, new CellFormat("#,###.######", CellStyle.ALIGN_RIGHT)); defaultFormatMap .put(Date.class, new CellFormat(ExcelDateFormats.getExcelFormatString(exportContext, DateFormatType.DATE_TIME_MINUTES))); defaultFormatMap.put(java.sql.Date.class, new CellFormat(ExcelDateFormats.getExcelFormatString(exportContext, DateFormatType.DATE))); defaultFormatMap.put(java.sql.Timestamp.class, new CellFormat(ExcelDateFormats.getExcelFormatString(exportContext, DateFormatType.DATE_TIME_MILLIS))); }
public MyXlsContentProvider(final ExportWorkbook workbook) { super(new MyXlsExportContext(), workbook); defaultFormatMap.put(DateHolder.class, new CellFormat("YYYY-MM-DD").setAutoDatePrecision(true)); // format unused. defaultFormatMap.put(DayHolder.class, new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE))); }
/** * @see XlsContentProvider#getCellFormat(ExportCell, java.lang.Object, java.lang.String, * java.util.Map) */ @Override protected CellFormat getCustomizedCellFormat(final CellFormat format, final Object value) { if (value == null || DateHolder.class.isAssignableFrom(value.getClass()) == false) { return null; } if (format != null && BooleanUtils.isTrue(format.getAutoDatePrecision()) == false) { return null; } // Find a format dependent on the precision: final DatePrecision precision = ((DateHolder) value).getPrecision(); if (precision == DatePrecision.DAY) { return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE)); } else if (precision == DatePrecision.SECOND) { return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE_TIME_SECONDS)); } else if (precision == DatePrecision.MILLISECOND) { return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE_TIME_MILLIS)); } else { // HOUR_OF_DAY, MINUTE, MINUTE_15 or null return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE_TIME_MINUTES)); } } }
cellFormat = new CellFormat(); cellFormat.setAlignment(CellStyle.ALIGN_LEFT); cellFormat.setDataFormat("@");