Class TransformerDelegator

java.lang.Object
org.jxls.transform.TransformerDelegator
All Implemented Interfaces:
Transformer

public class TransformerDelegator extends Object implements Transformer
Decorator pattern for Transformer, in particular write() can be extended overriding beforeWrite()
  • Field Details

    • transformer

      protected final Transformer transformer
  • Constructor Details

    • TransformerDelegator

      public TransformerDelegator(Transformer transformer)
  • Method Details

    • transform

      public void transform(CellRef srcCellRef, CellRef targetCellRef, Context context, boolean updateRowHeight)
      Specified by:
      transform in interface Transformer
    • setOutputStream

      public void setOutputStream(OutputStream outputStream)
      Specified by:
      setOutputStream in interface Transformer
    • writeButNotCloseStream

      public void writeButNotCloseStream() throws IOException
      Description copied from interface: Transformer
      Writes Excel workbook to output stream but not close the stream designed to use with ZipOutputStream or other OutputStream for creates several xls files one time.
      Specified by:
      writeButNotCloseStream in interface Transformer
      Throws:
      IOException - -
    • beforeWrite

      protected void beforeWrite()
    • write

      public void write() throws IOException
      Description copied from interface: Transformer
      Writes Excel workbook to output stream and disposes the workbook.
      Specified by:
      write in interface Transformer
      Throws:
      IOException - -
    • dispose

      public void dispose()
      Description copied from interface: Transformer
      Must be called after use. write() calls this method.
      Specified by:
      dispose in interface Transformer
    • setFormula

      public void setFormula(CellRef cellRef, String formulaString)
      Specified by:
      setFormula in interface Transformer
    • getFormulaCells

      public Set<CellData> getFormulaCells()
      Specified by:
      getFormulaCells in interface Transformer
    • getCellData

      public CellData getCellData(CellRef cellRef)
      Specified by:
      getCellData in interface Transformer
    • getTargetCellRef

      public List<CellRef> getTargetCellRef(CellRef cellRef)
      Specified by:
      getTargetCellRef in interface Transformer
      Parameters:
      cellRef - a source cell reference
      Returns:
      a list of cell references into which the source cell was transformed
    • resetTargetCellRefs

      public void resetTargetCellRefs()
      Specified by:
      resetTargetCellRefs in interface Transformer
    • resetArea

      public void resetArea(AreaRef areaRef)
      Specified by:
      resetArea in interface Transformer
    • clearCell

      public void clearCell(CellRef cellRef)
      Specified by:
      clearCell in interface Transformer
    • getCommentedCells

      public List<CellData> getCommentedCells()
      Specified by:
      getCommentedCells in interface Transformer
    • deleteSheet

      public boolean deleteSheet(String sheetName)
      Specified by:
      deleteSheet in interface Transformer
    • setHidden

      public void setHidden(String sheetName, boolean hidden)
      Specified by:
      setHidden in interface Transformer
    • updateRowHeight

      public void updateRowHeight(String srcSheetName, int srcRowNum, String targetSheetName, int targetRowNum)
      Specified by:
      updateRowHeight in interface Transformer
    • adjustTableSize

      public void adjustTableSize(CellRef ref, Size size)
      Specified by:
      adjustTableSize in interface Transformer
    • isEvaluateFormulas

      public boolean isEvaluateFormulas()
      Description copied from interface: Transformer
      This property is used to recalculate all formulas before saving the workbook. This property is set to true if you don't open the file with MS Excel and just read it (e.g. with a unit test). The following documentation is POI specific.
      Specified by:
      isEvaluateFormulas in interface Transformer
      Returns:
      true: calls workbook.getCreationHelper().createFormulaEvaluator().evaluateAll() before writing the workbook. Please have a look at the POI documentation for more details. This does not work for streaming. Please be aware that POI supports only a subset of Excel formulas. If an unsupported formula is in the template the evaluation will fail.

      false (default): do nothing (hopefully MS Excel will recalculate all formulas while opening the file)

    • setEvaluateFormulas

      public void setEvaluateFormulas(boolean evaluateFormulas)
      Description copied from interface: Transformer
      This property is used to recalculate all formulas before saving the workbook. This property is set to true if you don't open the file with MS Excel and just read it (e.g. with a unit test). The following documentation is POI specific.
      Specified by:
      setEvaluateFormulas in interface Transformer
      Parameters:
      evaluateFormulas - true: calls workbook.getCreationHelper().createFormulaEvaluator().evaluateAll() before writing the workbook. Please have a look at the POI documentation for more details. This does not work for streaming. Please be aware that POI supports only a subset of Excel formulas. If an unsupported formula is in the template the evaluation will fail.

      false (default): do nothing (hopefully MS Excel will recalculate all formulas while opening the file)

    • isFullFormulaRecalculationOnOpening

      public boolean isFullFormulaRecalculationOnOpening()
      Specified by:
      isFullFormulaRecalculationOnOpening in interface Transformer
      Returns:
      false: do nothing, true: activate recalculation when opening
    • setFullFormulaRecalculationOnOpening

      public void setFullFormulaRecalculationOnOpening(boolean fullFormulaRecalculationOnOpening)
      Description copied from interface: Transformer
      If you set this option to true, all formulas will be recalculated when the file is opened in MS Excel. This changes the Excel file. This only works once.
      Specified by:
      setFullFormulaRecalculationOnOpening in interface Transformer
      Parameters:
      fullFormulaRecalculationOnOpening - false: do nothing (default value), true: activate recalculation when opening
    • isForwardOnly

      public boolean isForwardOnly()
      Specified by:
      isForwardOnly in interface Transformer
      Returns:
      true if the transformer can process cells only in a single pass
    • setLogger

      public void setLogger(JxlsLogger logger)
      Specified by:
      setLogger in interface Transformer
      Parameters:
      logger - not null
    • getLogger

      public JxlsLogger getLogger()
      Specified by:
      getLogger in interface Transformer
      Returns:
      never null
    • setIgnoreColumnProps

      public void setIgnoreColumnProps(boolean ignoreColumnProps)
      Specified by:
      setIgnoreColumnProps in interface Transformer
    • setIgnoreRowProps

      public void setIgnoreRowProps(boolean ignoreRowProps)
      Specified by:
      setIgnoreRowProps in interface Transformer