Package org.openxava.util.jxls
Class JxlsStyle
- java.lang.Object
-
- org.openxava.util.jxls.JxlsStyle
-
- All Implemented Interfaces:
JxlsConstants
public class JxlsStyle extends java.lang.Object implements JxlsConstants
JxlsStyle: a class to wrap and simplify the use of Apache POI CellStyle in the context of OpenXava Principle: JxlsStyle should not be instantiated directly, but rather created through workbook.addStyle(style) each setProperty returns the style so the setProperty's can be chained Usage:JxlsWorkbook wb = new JxlsWorkbook("Test"); JxlsSheet sheet = wb.addSheet("Test"); JxlsStyle boldCenteredTextS = wb.addStyle(TEXT).setAlign(CENTER).setBold(); JxlsStyle boldCenteredTextBorderedS = wb.addClonedStyle(boldCenteredTextS).setBorder(BOTTOM, BORDER_THIN); sheet.setValue(3, 4, "Pi", boldCenteredTextS); sheet.setValue(4, 4, "Pi", boldCenteredTextBorderedS);
- Author:
- Laurent Wibaux
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.poi.ss.usermodel.CellStyle
cellStyle
-
Fields inherited from interface org.openxava.util.jxls.JxlsConstants
ALL, AUTO_SIZE, BLACK, BLUE, BOLD, BORDER_NONE, BORDER_THICK, BORDER_THIN, BOTTOM, CENTER, DATE, EMPTY, FLOAT, GREEN, INTEGER, LEFT, LEFT_RIGHT, LIGHT_GREEN, LIGHT_GREY, LIGHT_YELLOW, NONE, PLAIN, RED, RIGHT, TEXT, TOP, TOP_BOTTOM, WHITE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
JxlsStyle(JxlsWorkbook workbook, java.lang.String name, int type)
protected
JxlsStyle(JxlsWorkbook workbook, java.lang.String name, java.lang.String format)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected JxlsStyle
clone(JxlsWorkbook workbook, java.lang.String name)
protected void
createPOICellStyle(JxlsWorkbook workbook, org.apache.poi.ss.usermodel.Workbook poiWorkbook)
JxlsStyle
setAlign(short align)
Sets the justification to use to render the content of the cellJxlsStyle
setBold()
Make the cell using this style boldJxlsStyle
setBold(boolean isBold)
Make the cell using this style bold or notJxlsStyle
setBorder(short place, short borderStyle)
Sets the borders for some of the sides of the cellJxlsStyle
setBorderColor(short borderColor)
Sets the border color for the 4 sides of the cellJxlsStyle
setBorders(short top, short bottom, short left, short right)
Sets the borders for the 4 sides of the cellJxlsStyle
setCellColor(short bgColor)
Sets the color to use to render the background of the cellJxlsStyle
setFontName(java.lang.String fontName)
Sets the font name to use in this styleJxlsStyle
setFontSize(int fontSize)
Sets the font size to use in this styleJxlsStyle
setFormat(java.lang.String format)
Sets the format to use to display numbers using this styleJxlsStyle
setTextColor(short textColor)
Sets the color to use to render the writing of the cellJxlsStyle
setWrap(boolean wraps)
Make the cell wraps its content
-
-
-
Constructor Detail
-
JxlsStyle
protected JxlsStyle(JxlsWorkbook workbook, java.lang.String name, int type)
-
JxlsStyle
protected JxlsStyle(JxlsWorkbook workbook, java.lang.String name, java.lang.String format)
-
-
Method Detail
-
clone
protected JxlsStyle clone(JxlsWorkbook workbook, java.lang.String name)
-
setFontName
public JxlsStyle setFontName(java.lang.String fontName)
Sets the font name to use in this style- Parameters:
fontName
- the name of the font- Returns:
- the style to chain other settings
-
setFontSize
public JxlsStyle setFontSize(int fontSize)
Sets the font size to use in this style- Parameters:
fontSize
- the size in points of the font- Returns:
- the style to chain other settings
-
setFormat
public JxlsStyle setFormat(java.lang.String format)
Sets the format to use to display numbers using this style- Parameters:
format
- the format encoded as per xls- Returns:
- the style to chain other settings
-
setBold
public JxlsStyle setBold()
Make the cell using this style bold- Returns:
- the style to chain other settings
-
setWrap
public JxlsStyle setWrap(boolean wraps)
Make the cell wraps its content- Returns:
- the style to chain other settings
-
setBold
public JxlsStyle setBold(boolean isBold)
Make the cell using this style bold or not- Parameters:
isBold
- true to set bold, false otherwise- Returns:
- the style to chain other settings
-
setTextColor
public JxlsStyle setTextColor(short textColor)
Sets the color to use to render the writing of the cell- Parameters:
textColor
- the color (one of JxlsConstants color, or one of HSSFColor.color.index)- Returns:
- the style to chain other settings
-
setCellColor
public JxlsStyle setCellColor(short bgColor)
Sets the color to use to render the background of the cell- Parameters:
bgColor
- the color (one of JxlsConstants color, or one of HSSFColor.?.index)- Returns:
- the style to chain other settings
-
setAlign
public JxlsStyle setAlign(short align)
Sets the justification to use to render the content of the cell- Parameters:
align
- the alignment (one of LEFT, CENTER, RIGHT)- Returns:
- the style to chain other settings
-
setBorders
public JxlsStyle setBorders(short top, short bottom, short left, short right)
Sets the borders for the 4 sides of the cell- Parameters:
top
- the border to use at the top (one of BORDER_NONE, BORDER_THIN, BORDER_THICK or CellStyle.BORDER_?)bottom
- the border to use at the bottomleft
- the border to use at the leftright
- the border to use at the right- Returns:
- the style to chain other settings
-
setBorder
public JxlsStyle setBorder(short place, short borderStyle)
Sets the borders for some of the sides of the cell- Parameters:
place
- the borders to sets (TOP, TOP+LEFT, TOP+BOTTOM...)borderStyle
- the border style to use (one of BORDER_NONE, BORDER_THIN, BORDER_THICK or CellStyle.BORDER_?)- Returns:
- the style to chain other settings
-
setBorderColor
public JxlsStyle setBorderColor(short borderColor)
Sets the border color for the 4 sides of the cell- Parameters:
borderColor
- the color (one of JxlsConstants color, or one of HSSFColor.color.index)- Returns:
- the style to chain other settings
-
createPOICellStyle
protected void createPOICellStyle(JxlsWorkbook workbook, org.apache.poi.ss.usermodel.Workbook poiWorkbook)
-
-