Class ExcelWriteUtil

java.lang.Object
jp.ecuacion.util.poi.excel.util.ExcelWriteUtil

public class ExcelWriteUtil extends Object
Provides excel writing related apache POI utility methods.
  • Constructor Details

    • ExcelWriteUtil

      public ExcelWriteUtil()
  • Method Details

    • createWorkbookWithSheet

      public org.apache.poi.ss.usermodel.Workbook createWorkbookWithSheet(String sheetName)
      Creates new workbook with adding sheet of name sheetName.
      Parameters:
      sheetName - sheetName
      Returns:
      Workbook
    • openForWrite

      public org.apache.poi.ss.usermodel.Workbook openForWrite(String filePath) throws org.apache.poi.EncryptedDocumentException, IOException
      Opens the excel file and returns Workbook object.
      Parameters:
      filePath - filePath
      Returns:
      workbook
      Throws:
      org.apache.poi.EncryptedDocumentException - EncryptedDocumentException
      IOException - IOException
    • openForOutput

      public FileOutputStream openForOutput(String filePath) throws org.apache.poi.EncryptedDocumentException, IOException
      Opens the excel file and returns Workbook object.
      Parameters:
      filePath - filePath
      Returns:
      workbook
      Throws:
      org.apache.poi.EncryptedDocumentException - EncryptedDocumentException
      IOException - IOException
    • saveToFile

      public void saveToFile(org.apache.poi.ss.usermodel.Workbook workbook, FileOutputStream out) throws org.apache.poi.EncryptedDocumentException, IOException
      Opens the excel file and returns Workbook object.
      Throws:
      org.apache.poi.EncryptedDocumentException
      IOException
    • getReadyToWriteTableData

      public <T> ExcelTable.ContextContainer getReadyToWriteTableData(ExcelTableWriter<T> writer, org.apache.poi.ss.usermodel.Workbook workbook, String sheetName) throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException
      Gets ready to write table data.
      Throws:
      jp.ecuacion.lib.core.exception.checked.BizLogicAppException
    • writeTableLine

      public <T> void writeTableLine(ExcelTableWriter<T> writer, ExcelTable.ContextContainer context, int rowNumber, List<T> columnList)
      Provides common procedure for write one line of a table.
    • evaluateAllFormulas

      public void evaluateAllFormulas(org.apache.poi.ss.usermodel.Workbook workbook) throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException
      Catches Exceptions which are thrown when workbook.getCreationHelper().createFormulaEvaluator().evaluateAll() is called and changes it to a BizLogicAppException with an appropriate message.

      When an excel file is created and uploaded by users, Exceptions according to the content of the file should be understandable to the users.

      Parameters:
      workbook - workbook
      Throws:
      jp.ecuacion.lib.core.exception.checked.BizLogicAppException - BizLogicAppException
    • evaluateAllFormulas

      public void evaluateAllFormulas(org.apache.poi.ss.usermodel.Workbook workbook, String fileInfo) throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException
      Catches Exceptions which are thrown when workbook.getCreationHelper().createFormulaEvaluator().evaluateAll() is called and changes it to a BizLogicAppException with an appropriate message.

      When an excel file is created and uploaded by users, Exceptions according to the content of the file should be understandable to the users.

      Parameters:
      workbook - workbook
      fileInfo - filename or file path of the excel file to add to the message
      Throws:
      jp.ecuacion.lib.core.exception.checked.BizLogicAppException - BizLogicAppException