ExcelFormatterpublic class DefaultExcelFormatter extends Object implements ExcelFormatter
| Modifier and Type | Class | Description |
|---|---|---|
protected static class |
DefaultExcelFormatter.StyleDescription |
Describes a style for a cell.
|
| Modifier and Type | Field | Description |
|---|---|---|
static String |
DEFAULT_DATE_FORMAT |
date format "dd.mm.yyyy hh:mm"
|
static short |
DEFAULT_FONT_COLOR |
Color Black
|
static String |
DEFAULT_FONT_NAME |
Arial font name
|
static short |
DEFAULT_FONT_SIZE |
Font Size 10
|
static String |
DEFAULT_INTEGER_FORMAT |
integer format "0"
|
static String |
DEFAULT_REAL_FORMAT |
real format "0.00"
|
static short |
HYPERLINK_FONT_COLOR |
Color Blue
|
| Constructor | Description |
|---|---|
DefaultExcelFormatter() |
Default constructor.
|
DefaultExcelFormatter(boolean emphasizeFirstRow) |
Constructor for defining the emphasizing of header rows.
|
DefaultExcelFormatter(boolean emphasizeFirstRow,
String defaultFontName,
Short defaultFontSize,
Short defaultFontColor,
Short defaultHyperlinkColor) |
Constructor for defining the various properties.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
finalize(ExcelWriter writer,
int rowCount,
int columnCount) |
Finalizes the workbook.
|
Short |
getAlign(ExcelWriter writer,
int row,
int column,
Object value) |
Returns the alignment to be used.
|
Short |
getBackgroundColor(ExcelWriter writer,
int row,
int column,
Object value) |
Returns the background color for the specified cell.
|
org.apache.poi.ss.usermodel.Font |
getBoldFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
Object value) |
Returns the bold font used for header rows.
|
Short |
getBottomBorderColor(ExcelWriter writer,
int row,
int column,
Object value) |
|
Short |
getBottomBorderThickness(ExcelWriter writer,
int row,
int column,
Object value) |
|
String |
getDateFormat(int row,
int column,
Object value) |
Returns the default format for dates.
|
protected Short |
getDateFormat(ExcelWriter writer,
String format) |
Returns the ID of the format or creates a new one if required.
|
org.apache.poi.ss.usermodel.Font |
getDefaultBoldFont(org.apache.poi.ss.usermodel.Workbook workbook) |
Returns the default bold font.
|
short |
getDefaultFontColor() |
Returns the font color to be used in non-hyperlink cells.
|
String |
getDefaultFontName() |
Returns the font name to be used.
|
short |
getDefaultFontSize() |
Returns the font size to be used.
|
short |
getDefaultHyperlinkColor() |
Returns the font color to be used for hyperlinks.
|
org.apache.poi.ss.usermodel.Font |
getDefaultHyperlinkFont(org.apache.poi.ss.usermodel.Workbook workbook) |
Returns the font to be used for hyperlinks.
|
org.apache.poi.ss.usermodel.Font |
getDefaultPlainFont(org.apache.poi.ss.usermodel.Workbook workbook) |
Returns the default font used for normal cells.
|
Short |
getFillPattern(ExcelWriter writer,
int row,
int column,
Object value) |
Returns the fill pattern for the background.
|
org.apache.poi.ss.usermodel.Font |
getFont(ExcelWriter writer,
int row,
int column,
Object value) |
Returns the correct font for the cell.
|
Short |
getForegroundColor(ExcelWriter writer,
int row,
int column,
Object value) |
Returns the foreground color for the specified cell.
|
Short |
getFormat(ExcelWriter writer,
int row,
int column,
Object value) |
Returns the display format.
|
org.apache.poi.ss.usermodel.Hyperlink |
getHyperlink(ExcelWriter writer,
int row,
int column,
Object value) |
Returns a hyperlink object when the given cell shall be linked.
|
org.apache.poi.ss.usermodel.Font |
getHyperlinkFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
Object value) |
Returns the font to be used for hyperlinks.
|
String |
getIntegerFormat(int row,
int column,
Object value) |
Returns the default format for shorts, integers and longs.
|
protected Short |
getIntegerFormat(ExcelWriter writer,
String format) |
Returns the ID of the format or creates a new one if required.
|
Short |
getLeftBorderColor(ExcelWriter writer,
int row,
int column,
Object value) |
|
Short |
getLeftBorderThickness(ExcelWriter writer,
int row,
int column,
Object value) |
|
org.apache.poi.ss.usermodel.Font |
getPlainFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
Object value) |
Returns the default font used for normal cells.
|
String |
getRealFormat(int row,
int column,
Object value) |
Returns the default format for real and float numbers.
|
protected Short |
getRealFormat(ExcelWriter writer,
String format) |
Returns the ID of the format or creates a new one if required.
|
Short |
getRightBorderColor(ExcelWriter writer,
int row,
int column,
Object value) |
|
Short |
getRightBorderThickness(ExcelWriter writer,
int row,
int column,
Object value) |
|
Short |
getTopBorderColor(ExcelWriter writer,
int row,
int column,
Object value) |
|
Short |
getTopBorderThickness(ExcelWriter writer,
int row,
int column,
Object value) |
|
void |
init() |
|
boolean |
isEmphasizeFirstRow() |
Returns the setting of emphasizing the header row.
|
boolean |
isTextWrap(ExcelWriter writer,
int row,
int column,
Object value) |
|
void |
setDefaultBorderColor(Short borderColor) |
|
void |
setDefaultBorderThickness(Short borderThickness) |
|
void |
setEmphasizeFirstRow(boolean emphasizeFirstRow) |
Sets the property of emphasizing header rows.
|
void |
setStyle(ExcelWriter writer,
org.apache.poi.ss.usermodel.Cell cell,
Object value) |
Sets the cell style.
|
public static final String DEFAULT_FONT_NAME
public static final short DEFAULT_FONT_COLOR
public static final short HYPERLINK_FONT_COLOR
public static final short DEFAULT_FONT_SIZE
public static final String DEFAULT_DATE_FORMAT
public static final String DEFAULT_INTEGER_FORMAT
public static final String DEFAULT_REAL_FORMAT
public DefaultExcelFormatter()
public DefaultExcelFormatter(boolean emphasizeFirstRow)
emphasizeFirstRow - whether row 0 shall be set in bold fontgetFont(ExcelWriter, int, int, Object)public DefaultExcelFormatter(boolean emphasizeFirstRow,
String defaultFontName,
Short defaultFontSize,
Short defaultFontColor,
Short defaultHyperlinkColor)
emphasizeFirstRow - whether row 0 shall be set in bold fontdefaultFontName - font name of default fontdefaultFontSize - font size to be useddefaultFontColor - color to be used for fontdefaultHyperlinkColor - color for hyperlinks to be usedgetFont(ExcelWriter, int, int, Object)public void init()
public void setStyle(ExcelWriter writer, org.apache.poi.ss.usermodel.Cell cell, Object value)
setStyle in interface ExcelFormatterwriter - writer that requires the informationcell - cell to be formattedvalue - value in cellgetFormat(ExcelWriter, int, int, Object),
getBackgroundColor(ExcelWriter, int, int, Object),
getFillPattern(ExcelWriter, int, int, Object),
getForegroundColor(ExcelWriter, int, int, Object),
getFont(ExcelWriter, int, int, Object),
getAlign(ExcelWriter, int, int, Object),
getHyperlink(ExcelWriter, int, int, Object)public org.apache.poi.ss.usermodel.Hyperlink getHyperlink(ExcelWriter writer, int row, int column, Object value)
getFont(ExcelWriter, int, int, Object)
when you return a hyperlink here.writer - the calling writerrow - row indexcolumn - column indexvalue - value in cellpublic void finalize(ExcelWriter writer, int rowCount, int columnCount)
ExcelWriter writes the
complete workbook to the underlying output stream.
This implementation just sets all columns to auto fit.finalize in interface ExcelFormatterwriter - the calling writerrowCount - the number of rows in the selected sheetcolumnCount - the number of columns modified in the selected sheetpublic Short getAlign(ExcelWriter writer, int row, int column, Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cellpublic Short getFormat(ExcelWriter writer, int row, int column, Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cellgetDateFormat(int, int, Object),
getIntegerFormat(int, int, Object),
getRealFormat(int, int, Object)protected Short getDateFormat(ExcelWriter writer, String format)
writer - writer that provides the workbookformat - format to be usedprotected Short getIntegerFormat(ExcelWriter writer, String format)
writer - writer that provides the workbookformat - format to be usedprotected Short getRealFormat(ExcelWriter writer, String format)
writer - writer that provides the workbookformat - format to be usedpublic String getDateFormat(int row, int column, Object value)
DEFAULT_DATE_FORMAT.row - the row that this format will be used forcolumn - the column that this format will be used forvalue - the value that this format will be used forDEFAULT_DATE_FORMATpublic String getIntegerFormat(int row, int column, Object value)
DEFAULT_INTEGER_FORMAT.row - the row that this format will be used forcolumn - the column that this format will be used forvalue - the value that this format will be used forDEFAULT_INTEGER_FORMATpublic String getRealFormat(int row, int column, Object value)
DEFAULT_REAL_FORMAT.row - the row that this format will be used forcolumn - the column that this format will be used forvalue - the value that this format will be used forDEFAULT_REAL_FORMATpublic Short getBackgroundColor(ExcelWriter writer, int row, int column, Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cellpublic Short getFillPattern(ExcelWriter writer, int row, int column, Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cellpublic Short getForegroundColor(ExcelWriter writer, int row, int column, Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cellpublic org.apache.poi.ss.usermodel.Font getFont(ExcelWriter writer, int row, int column, Object value)
font = writer.getWorkbook().createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setColor(IndexedColors.BLACK.getIndex());
font.setFontHeightInPoints((short)10);
font.setFontName("Arial");
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cellgetBoldFont(Workbook, int, int, Object),
getPlainFont(Workbook, int, int, Object),
getHyperlinkFont(Workbook, int, int, Object)public short getDefaultFontSize()
DEFAULT_FONT_SIZEpublic short getDefaultFontColor()
DEFAULT_FONT_COLORpublic short getDefaultHyperlinkColor()
public String getDefaultFontName()
public boolean isEmphasizeFirstRow()
public void setEmphasizeFirstRow(boolean emphasizeFirstRow)
emphasizeFirstRow - the emphasizeFirstRow to setpublic org.apache.poi.ss.usermodel.Font getBoldFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
Object value)
getDefaultBoldFont(Workbook).row - the row that this font will be used forcolumn - the column that this font will be used forvalue - the value that this font will be used forworkbook - the workbook for creationgetDefaultBoldFont(Workbook)public org.apache.poi.ss.usermodel.Font getDefaultBoldFont(org.apache.poi.ss.usermodel.Workbook workbook)
getDefaultFontName(),
getDefaultFontSize() and getDefaultFontColor() with bold weight.workbook - workbook object for creationpublic org.apache.poi.ss.usermodel.Font getPlainFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
Object value)
getDefaultPlainFont(Workbook).row - the row that this font will be used forcolumn - the column that this font will be used forvalue - the value that this font will be used forworkbook - the workbook for creationpublic org.apache.poi.ss.usermodel.Font getDefaultPlainFont(org.apache.poi.ss.usermodel.Workbook workbook)
getDefaultFontName(),
getDefaultFontSize() and getDefaultFontColor() with normal weight.workbook - the workbook for creationpublic org.apache.poi.ss.usermodel.Font getHyperlinkFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
Object value)
getDefaultHyperlinkFont(Workbook).workbook - the workbook for creationrow - the row that this font will be used forcolumn - the column that this font will be used forvalue - the value that this font will be used forpublic org.apache.poi.ss.usermodel.Font getDefaultHyperlinkFont(org.apache.poi.ss.usermodel.Workbook workbook)
getDefaultFontName(),
getDefaultFontSize() and getDefaultHyperlinkColor(). This font will
be underlined with normal weight.workbook - the workbook for creationpublic Short getTopBorderColor(ExcelWriter writer, int row, int column, Object value)
public Short getLeftBorderColor(ExcelWriter writer, int row, int column, Object value)
public Short getRightBorderColor(ExcelWriter writer, int row, int column, Object value)
public Short getBottomBorderColor(ExcelWriter writer, int row, int column, Object value)
public Short getTopBorderThickness(ExcelWriter writer, int row, int column, Object value)
public Short getLeftBorderThickness(ExcelWriter writer, int row, int column, Object value)
public Short getRightBorderThickness(ExcelWriter writer, int row, int column, Object value)
public Short getBottomBorderThickness(ExcelWriter writer, int row, int column, Object value)
public void setDefaultBorderColor(Short borderColor)
borderColor - the borderColor to setpublic void setDefaultBorderThickness(Short borderThickness)
borderThickness - the borderThickness to setpublic boolean isTextWrap(ExcelWriter writer, int row, int column, Object value)
Copyright © 2018. All rights reserved.