|
Copyright © 2008-2011 Ralph Schuster. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcsv.impl.DefaultExcelFormatter
public class DefaultExcelFormatter
Default implementation of an ExcelFormatter. This class provides a default implementation that provides some basic functionality to emphasize the header row in a sheet by a bold font and formatting hyperlinks in cells. You can derive from this implementation to change formatting, e.g. just setting another color or font size.
| Nested Class Summary | |
|---|---|
protected class |
DefaultExcelFormatter.StyleDescription
|
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_DATE_FORMAT
date format "dd.mm.yyyy hh:mm" |
static short |
DEFAULT_FONT_COLOR
Color Black |
static java.lang.String |
DEFAULT_FONT_NAME
Arial font name |
static short |
DEFAULT_FONT_SIZE
Font Size 10 |
static java.lang.String |
DEFAULT_INTEGER_FORMAT
integer format "0" |
static java.lang.String |
DEFAULT_REAL_FORMAT
real format "0.00" |
static short |
HYPERLINK_FONT_COLOR
Color Blue |
| Constructor Summary | |
|---|---|
DefaultExcelFormatter()
Default constructor. |
|
DefaultExcelFormatter(boolean emphasizeFirstRow)
Constructor for defining the emphasizing of header rows. |
|
DefaultExcelFormatter(boolean emphasizeFirstRow,
java.lang.String defaultFontName,
java.lang.Short defaultFontSize,
java.lang.Short defaultFontColor,
java.lang.Short defaultHyperlinkColor)
Constructor for defining the various properties. |
|
| Method Summary | |
|---|---|
void |
finalize(ExcelWriter writer,
int rowCount,
int columnCount)
Finalizes the workbook. |
java.lang.Short |
getAlign(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
Returns the alignment to be used. |
java.lang.Short |
getBackgroundColor(ExcelWriter writer,
int row,
int column,
java.lang.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,
java.lang.Object value)
Returns the bold font used for header rows. |
java.lang.Short |
getBottomBorderColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
java.lang.Short |
getBottomBorderThickness(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
protected java.lang.Short |
getDateFormat(ExcelWriter writer,
java.lang.String format)
Returns the ID of the format or creates a new one if required. |
java.lang.String |
getDateFormat(int row,
int column,
java.lang.Object value)
Returns the default format for dates. |
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. |
java.lang.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. |
java.lang.Short |
getFillPattern(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
Returns the fill pattern for the background. |
org.apache.poi.ss.usermodel.Font |
getFont(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
Returns the correct font for the cell. |
java.lang.Short |
getForegroundColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
Returns the foreground color for the specified cell. |
java.lang.Short |
getFormat(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
Returns the display format. |
org.apache.poi.ss.usermodel.Hyperlink |
getHyperlink(ExcelWriter writer,
int row,
int column,
java.lang.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,
java.lang.Object value)
Returns the font to be used for hyperlinks. |
protected java.lang.Short |
getIntegerFormat(ExcelWriter writer,
java.lang.String format)
Returns the ID of the format or creates a new one if required. |
java.lang.String |
getIntegerFormat(int row,
int column,
java.lang.Object value)
Returns the default format for shorts, integers and longs. |
java.lang.Short |
getLeftBorderColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
java.lang.Short |
getLeftBorderThickness(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
org.apache.poi.ss.usermodel.Font |
getPlainFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
java.lang.Object value)
Returns the default font used for normal cells. |
protected java.lang.Short |
getRealFormat(ExcelWriter writer,
java.lang.String format)
Returns the ID of the format or creates a new one if required. |
java.lang.String |
getRealFormat(int row,
int column,
java.lang.Object value)
Returns the default format for real and float numbers. |
java.lang.Short |
getRightBorderColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
java.lang.Short |
getRightBorderThickness(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
java.lang.Short |
getTopBorderColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
java.lang.Short |
getTopBorderThickness(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
void |
init()
|
boolean |
isEmphasizeFirstRow()
Returns the setting of emphasizing the header row. |
boolean |
isTextWrap(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
void |
setDefaultBorderColor(java.lang.Short borderColor)
|
void |
setDefaultBorderThickness(java.lang.Short borderThickness)
|
void |
setEmphasizeFirstRow(boolean emphasizeFirstRow)
Sets the property of emphasizing header rows. |
void |
setStyle(ExcelWriter writer,
org.apache.poi.ss.usermodel.Cell cell,
java.lang.Object value)
Sets the cell style. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.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 java.lang.String DEFAULT_DATE_FORMAT
public static final java.lang.String DEFAULT_INTEGER_FORMAT
public static final java.lang.String DEFAULT_REAL_FORMAT
| Constructor Detail |
|---|
public DefaultExcelFormatter()
public DefaultExcelFormatter(boolean emphasizeFirstRow)
emphasizeFirstRow - whether row 0 shall be set in bold fontgetFont(ExcelWriter, int, int, Object)
public DefaultExcelFormatter(boolean emphasizeFirstRow,
java.lang.String defaultFontName,
java.lang.Short defaultFontSize,
java.lang.Short defaultFontColor,
java.lang.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)| Method Detail |
|---|
public void init()
public void setStyle(ExcelWriter writer,
org.apache.poi.ss.usermodel.Cell cell,
java.lang.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,
java.lang.Object value)
getFont(ExcelWriter, int, int, Object)
when you return a hyperlink here.
writer - the calling writerrow - row indexcolumn - column indexvalue - value in cell
public 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 sheet
public java.lang.Short getAlign(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cell
public java.lang.Short getFormat(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cell
getDateFormat(int, int, Object),
getIntegerFormat(int, int, Object),
getRealFormat(int, int, Object)
protected java.lang.Short getDateFormat(ExcelWriter writer,
java.lang.String format)
writer - writer that provides the workbookformat - format to be used
protected java.lang.Short getIntegerFormat(ExcelWriter writer,
java.lang.String format)
writer - writer that provides the workbookformat - format to be used
protected java.lang.Short getRealFormat(ExcelWriter writer,
java.lang.String format)
writer - writer that provides the workbookformat - format to be used
public java.lang.String getDateFormat(int row,
int column,
java.lang.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 for
DEFAULT_DATE_FORMAT
public java.lang.String getIntegerFormat(int row,
int column,
java.lang.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 for
DEFAULT_INTEGER_FORMAT
public java.lang.String getRealFormat(int row,
int column,
java.lang.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 for
DEFAULT_REAL_FORMAT
public java.lang.Short getBackgroundColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cell
public java.lang.Short getFillPattern(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cell
public java.lang.Short getForegroundColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
writer - writer that requires the informationrow - row indexcolumn - column indexvalue - value in cell
public org.apache.poi.ss.usermodel.Font getFont(ExcelWriter writer,
int row,
int column,
java.lang.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 cell
getBoldFont(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 java.lang.String getDefaultFontName()
public boolean isEmphasizeFirstRow()
public void setEmphasizeFirstRow(boolean emphasizeFirstRow)
emphasizeFirstRow - the emphasizeFirstRow to set
public org.apache.poi.ss.usermodel.Font getBoldFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
java.lang.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 creation
getDefaultBoldFont(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 creation
public org.apache.poi.ss.usermodel.Font getPlainFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
java.lang.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 creation
public 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 creation
public org.apache.poi.ss.usermodel.Font getHyperlinkFont(org.apache.poi.ss.usermodel.Workbook workbook,
int row,
int column,
java.lang.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 for
public 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 creation
public java.lang.Short getTopBorderColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
public java.lang.Short getLeftBorderColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
public java.lang.Short getRightBorderColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
public java.lang.Short getBottomBorderColor(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
public java.lang.Short getTopBorderThickness(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
public java.lang.Short getLeftBorderThickness(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
public java.lang.Short getRightBorderThickness(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
public java.lang.Short getBottomBorderThickness(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
public void setDefaultBorderColor(java.lang.Short borderColor)
borderColor - the borderColor to setpublic void setDefaultBorderThickness(java.lang.Short borderThickness)
borderThickness - the borderThickness to set
public boolean isTextWrap(ExcelWriter writer,
int row,
int column,
java.lang.Object value)
|
Copyright © 2008-2011 Ralph Schuster. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||