Class 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 Detail

      • cellStyle

        protected org.apache.poi.ss.usermodel.CellStyle cellStyle
    • 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

      • 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 bottom
        left - the border to use at the left
        right - 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)