Class CellStyleCreator

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.apache.poi.ss.usermodel.CellStyle baseStyle  
      private org.apache.poi.ss.usermodel.DataFormat dataFormat  
      private Map<org.apache.poi.ss.usermodel.CellStyle,​Map<String,​org.apache.poi.ss.usermodel.CellStyle>> styles  
      private org.apache.poi.ss.usermodel.Workbook workbook  
    • Constructor Summary

      Constructors 
      Constructor Description
      CellStyleCreator​(org.apache.poi.ss.usermodel.Workbook workbook)
      Creates a new style creator for the given Excel workbook.
    • Field Detail

      • workbook

        private final org.apache.poi.ss.usermodel.Workbook workbook
      • dataFormat

        private final org.apache.poi.ss.usermodel.DataFormat dataFormat
      • styles

        private final Map<org.apache.poi.ss.usermodel.CellStyle,​Map<String,​org.apache.poi.ss.usermodel.CellStyle>> styles
      • baseStyle

        private org.apache.poi.ss.usermodel.CellStyle baseStyle
    • Constructor Detail

      • CellStyleCreator

        public CellStyleCreator​(org.apache.poi.ss.usermodel.Workbook workbook)
        Creates a new style creator for the given Excel workbook.
    • Method Detail

      • convertJavaDateFormatToExcelFormat

        public static String convertJavaDateFormatToExcelFormat​(String javaFormat)
        Converts a Java date format string to the corresponding Excel date format string.
      • createStyle

        public org.apache.poi.ss.usermodel.CellStyle createStyle()
        Create a new cell style.
      • createFont

        public org.apache.poi.ss.usermodel.Font createFont()
        Create a new font style.
      • getBaseStyle

        public org.apache.poi.ss.usermodel.CellStyle getBaseStyle()
        Get the current base style for new cells.
      • setBaseStyle

        public void setBaseStyle​(org.apache.poi.ss.usermodel.CellStyle baseStyle)
        Set a base style to use for new cells. When a base style has been set it used as a template for all new styles that are created with getCellStyle(String). This can be useful for setting different fonts, colors, etc.
      • getIntCellStyle

        public org.apache.poi.ss.usermodel.CellStyle getIntCellStyle()
        Get the cell style for formatting numbers without decimals. This is equivalent to getCellStyle(String) with "0" as parameter.
      • getDateCellStyle

        public org.apache.poi.ss.usermodel.CellStyle getDateCellStyle​(String javaFormat)
        Get the cell style for the given date format string. If a style already exists it is re-used, otherwise a new style is created. Note that if the format string is a date format string, it must be in Java format. Use getCellStyle(String) if the format string is in Excel format.
        Parameters:
        javaFormat - The Java format string
      • getCellStyle

        public org.apache.poi.ss.usermodel.CellStyle getCellStyle​(String format)
        Get the cell style for the given format string. If a style already exists it is re-used, otherwise a new style is created. Note that if the format string is a date format string, it must be in Excel format. Use getDateCellStyle(String) if the format string is in Java format.
        Parameters:
        format - The format string