Class JKExcelUtil

java.lang.Object
com.jk.core.util.JKExcelUtil

public class JKExcelUtil extends Object
This class is a utility class used for creating and writing Excel sheets using Apache POI.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
    This method constructs a new JKExcelUtil from the data available in the JKTableModel.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    This method builds an Excel sheet using the provided JKTableModel and displays it.
    protected void
    This method creates the column headers in the work sheet.
    protected void
    createRow(int rowIndex)
    This method inserts a new row at the specified index in the work sheet.
    protected void
    This method creates all the rows specified in the JKTableModel.
    protected void
    This method sets the width of columns to auto-fit its content.
    void
    writeTo(File file)
    This method writes the Excel sheet to the specified file.
    void
    This method writes the Excel sheet to the specified output stream.

    Methods inherited from class java.lang.Object

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

    • JKExcelUtil

      public JKExcelUtil(JKTableModel model)
      This method constructs a new JKExcelUtil from the data available in the JKTableModel.
      Parameters:
      model - Specifies the JKTableModel representing the data to be written to the sheet.
  • Method Details

    • buildExcelSheet

      public static void buildExcelSheet(JKTableModel model)
      This method builds an Excel sheet using the provided JKTableModel and displays it.
      Parameters:
      model - Specifies the JKTableModel representing the data to be written to the sheet.
    • createColumnHeaders

      protected void createColumnHeaders()
      This method creates the column headers in the work sheet.
    • createRow

      protected void createRow(int rowIndex)
      This method inserts a new row at the specified index in the work sheet.
      Parameters:
      rowIndex - Specifies the row index that the new row will be inserted in.
    • createRows

      protected void createRows()
      This method creates all the rows specified in the JKTableModel.
    • setColumnsWidth

      protected void setColumnsWidth()
      This method sets the width of columns to auto-fit its content.
    • writeTo

      public void writeTo(File file) throws IOException
      This method writes the Excel sheet to the specified file.
      Parameters:
      file - Specifies the file to write the Excel sheet to.
      Throws:
      IOException - if an I/O exception has occurred.
    • writeTo

      public void writeTo(OutputStream out) throws IOException
      This method writes the Excel sheet to the specified output stream.
      Parameters:
      out - Specifies the output stream to write the Excel sheet to.
      Throws:
      IOException - if an I/O exception has occurred.