ExcelUtil
Functions
Starts as the last row number of the sheet and looks up in the column to find the first non-null cell
Creates a sheet within the workbook with the name. If a sheet already exists with the same name then a new sheet with name sheetName_n, where n is the current number of sheets in the workbook is created. Sheet names must follow Excel naming conventions.
Exports the data in the ResultSet to an Excel worksheet. The ResultSet is assumed to be forward only and each row is processed until all rows are exported. The ResultSet is closed after the processing.
Writes each table in the list to an Excel workbook with each table being placed in a new sheet with the sheet name equal to the name of the table. The column names for each table are written as the first row of each sheet.
Copies the rows from the sheet to the table. The copy is assumed to start at row 1, column 1 (i.e. cell A1) and proceed to the right for the number of columns in the table and the number of rows of the sheet. The copy is from the perspective of the table. That is, all columns of a row of the table are attempted to be filled from a corresponding row of the sheet. If the row of the sheet does not have cell values for the corresponding column, then the cell is interpreted as a null value when being placed in the corresponding column. It is up to the client to ensure that the cells in a row of the sheet are data type compatible with the corresponding column in the table. Any rows that cannot be transfer in their entirety are logged to the supplied PrintWriter
Opens the workbook for reading only and writes the sheets of the workbook into database tables. The list of names is the names of the sheets in the workbook and the names of the tables that need to be written. They are in the order that is required for entering data so that no integrity constraints are violated. The underlying workbook is closed after the operation.
Assumes that the first row is a header for a CSV like file and returns the number of columns (1 for each header)
Assumes that the first row is a header for a CSV like file and returns the number of columns (1 for each header)
IO exceptions are squelched in this method. If there is a problem, then null is returned. Opens an Apache POI XSSFWorkbook instance. The user is responsible for closing the workbook when done. Do not try to write to the returned workbook.
Reads the Excel cell and translates it into a Java object
Reads the Excel cell and translates it into a String
Read a row assuming a fixed number of columns. Cells that are missing/null in the row are read as null objects.
Read a row assuming a fixed number of columns. Cells that are missing/null in the row are read as null Strings.
Read a row assuming a fixed number of columns. Cells that are missing/null in the row are read as null Strings.
This is the reverse operation to the function writeToExcel() for a Map
Treats the columns as fields in a csv file, writes each row as a separate csv row in the resulting csv file