Package com.jk.core.util
Class JKExcelUtil
java.lang.Object
com.jk.core.util.JKExcelUtil
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
ConstructorsConstructorDescriptionJKExcelUtil
(JKTableModel model) This method constructs a newJKExcelUtil
from the data available in theJKTableModel
. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
buildExcelSheet
(JKTableModel model) This method builds an Excel sheet using the providedJKTableModel
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 theJKTableModel
.protected void
This method sets the width of columns to auto-fit its content.void
This method writes the Excel sheet to the specified file.void
writeTo
(OutputStream out) This method writes the Excel sheet to the specified output stream.
-
Constructor Details
-
JKExcelUtil
This method constructs a newJKExcelUtil
from the data available in theJKTableModel
.- Parameters:
model
- Specifies theJKTableModel
representing the data to be written to the sheet.
-
-
Method Details
-
buildExcelSheet
This method builds an Excel sheet using the providedJKTableModel
and displays it.- Parameters:
model
- Specifies theJKTableModel
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 theJKTableModel
. -
setColumnsWidth
protected void setColumnsWidth()This method sets the width of columns to auto-fit its content. -
writeTo
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
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.
-