Package csv.util

Class WorkbookCellStyles

java.lang.Object
csv.util.WorkbookCellStyles

public class WorkbookCellStyles extends Object
Help with the styles in a workbook.

Use this helper when u need different styles in a workbook and refer to them by name.

Author:
ralph
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    WorkbookCellStyles(org.apache.poi.ss.usermodel.Workbook workbook)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.poi.ss.usermodel.CellStyle
    Creates a style of the given name.
    org.apache.poi.ss.usermodel.Font
    Returns the default bold font.
    org.apache.poi.ss.usermodel.DataFormat
    Returns the data format object of the workbook.
    org.apache.poi.ss.usermodel.Font
    Returns the default bold font.
    org.apache.poi.ss.usermodel.CellStyle
    Returns the cached cell style of the given name.
    org.apache.poi.ss.usermodel.Workbook
    Returns the workbook.
    org.apache.poi.ss.usermodel.CellStyle
    setStyle(org.apache.poi.ss.usermodel.Cell cell, String name)
    Set the style in the given cell according to the cell style name.
    org.apache.poi.ss.usermodel.CellStyle
    setStyle(org.apache.poi.ss.usermodel.Row row, int col, String name)
    Set the style in the given row cell according to the cell style name.
    org.apache.poi.ss.usermodel.CellStyle
    setStyle(org.apache.poi.ss.usermodel.Sheet sheet, int row, int col, String name)
    Set the style in the given sheet cell according to the ceel style name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WorkbookCellStyles

      public WorkbookCellStyles(org.apache.poi.ss.usermodel.Workbook workbook)
      Constructor.
      Parameters:
      workbook - - the workbook this helper is attached to.
  • Method Details

    • getStyle

      public org.apache.poi.ss.usermodel.CellStyle getStyle(String name)
      Returns the cached cell style of the given name.

      The method will call createStyle(String) when the style was not created yet.invalid input: '<'/

      Parameters:
      name - - name of the style.
      Returns:
      the style of the given name or null if it cannot be found or created.
      See Also:
    • setStyle

      public org.apache.poi.ss.usermodel.CellStyle setStyle(org.apache.poi.ss.usermodel.Sheet sheet, int row, int col, String name)
      Set the style in the given sheet cell according to the ceel style name.
      Parameters:
      sheet - - sheet that the cell belongs to
      row - - row index of cell
      col - - column index of cell
      name - - name of style to be set
      Returns:
      the cell style that was applied.
      See Also:
    • setStyle

      public org.apache.poi.ss.usermodel.CellStyle setStyle(org.apache.poi.ss.usermodel.Row row, int col, String name)
      Set the style in the given row cell according to the cell style name.
      Parameters:
      row - - row the cell belongs to
      col - - column index of cell
      name - - name of style to be set
      Returns:
      the cell style that was applied.
      See Also:
    • setStyle

      public org.apache.poi.ss.usermodel.CellStyle setStyle(org.apache.poi.ss.usermodel.Cell cell, String name)
      Set the style in the given cell according to the cell style name.
      Parameters:
      cell - - the sell to be modified
      name - - name of style to be set
      Returns:
      the cell style that was applied.
    • createStyle

      protected org.apache.poi.ss.usermodel.CellStyle createStyle(String name)
      Creates a style of the given name.

      Descendants must override this method to create the cell style for their specific usage.

      Parameters:
      name - - name of the cell style to be created
      Returns:
      the cell style of the given name or null
      See Also:
    • getWorkbook

      public org.apache.poi.ss.usermodel.Workbook getWorkbook()
      Returns the workbook.
      Returns:
      the workbook.
    • getBoldFont

      public org.apache.poi.ss.usermodel.Font getBoldFont()
      Returns the default bold font.
      Returns:
      bold font
      See Also:
    • getPlainFont

      public org.apache.poi.ss.usermodel.Font getPlainFont()
      Returns the default bold font.
      Returns:
      bold font
      See Also:
    • getDataFormat

      public org.apache.poi.ss.usermodel.DataFormat getDataFormat()
      Returns the data format object of the workbook.
      Returns:
      the data format object of the workbook.