@Override public void processRecord(Record record) { switch (record.getSid()) { case BoundSheetRecord.sid: BoundSheetRecord boundSheetRecord = (BoundSheetRecord) record; parsedDataMap.put(boundSheetRecord.getSheetname(), new ArrayList<List<Object>>()); boundSheetRecords.add(boundSheetRecord); missingRows.put(boundSheetRecord.getSheetname(), new ArrayList<Integer>()); missingCells.put(boundSheetRecord.getSheetname(), new ArrayList<int[]>()); break; case BOFRecord.sid: BOFRecord bofRecord = (BOFRecord) record; bofRecordType = bofRecord.getType(); switch (bofRecordType) { case BOFRecord.TYPE_WORKBOOK: LOG.trace("loading excel data information."); break; case BOFRecord.TYPE_WORKSHEET: sheetIndex += 1; sheetName = boundSheetRecords.get(sheetIndex).getSheetname(); currentSheet = parsedDataMap.get(sheetName); originalRowIndex = 0; maxColumnlength = -1; currentRow = new ArrayList<Object>(); break; } break; case RowRecord.sid: RowRecord rowRecord = (RowRecord) record; int firstColumn = rowRecord.getFirstCol(); int lastColumn = rowRecord.getLastCol(); int length = lastColumn - firstColumn; if (length > maxColumnlength) { maxColumnlength = length; } break; case BlankRecord.sid: BlankRecord blankRecord = (BlankRecord) record; missingCells.get(sheetName).add(new int[] {blankRecord.getColumn(), blankRecord.getRow()}); currentRow.add(null); break; case BoolErrRecord.sid: BoolErrRecord boolErrRecord = (BoolErrRecord) record; if (boolErrRecord.isBoolean()) { currentRow.add(boolErrRecord.getErrorValue() == BOOLEAN_CELL_TRUE_FLAG); } else if (boolErrRecord.isError()) { LOG.warn(boolErrRecord); } break; case FormulaRecord.sid: FormulaRecord formulaRecord = (FormulaRecord) record; LOG.trace( "formulaRecord:[" + formulaRecord.getColumn() + "," + formulaRecord.getRow() + "]"); break; case StringRecord.sid: StringRecord stringRecord = (StringRecord) record; currentRow.add(stringRecord.getString()); break; case LabelRecord.sid: LabelRecord labelRecord = (LabelRecord) record; currentRow.add(labelRecord.getValue()); break; case LabelSSTRecord.sid: LabelSSTRecord labelSSTRecord = (LabelSSTRecord) record; currentRow.add( sheetRecordCollectingListener .getSSTRecord() .getString(labelSSTRecord.getSSTIndex()) .getString()); break; case NoteRecord.sid: NoteRecord notegRecord = (NoteRecord) record; LOG.trace("formulaRecord:[" + notegRecord.getColumn() + "," + notegRecord.getRow() + "]"); break; case NumberRecord.sid: NumberRecord numberRecord = (NumberRecord) record; double numberValue = numberRecord.getValue(); int formatIndex = formatTrackingHSSFListener.getFormatIndex(numberRecord); if (HSSFDateUtil.isInternalDateFormat(formatIndex)) { currentRow.add(HSSFDateUtil.getJavaDate(numberValue)); } else { currentRow.add(numberValue); } break; case RKRecord.sid: RKRecord pkRecord = (RKRecord) record; currentRow.add(pkRecord.getRKNumber()); break; case EOFRecord.sid: switch (bofRecordType) { case BOFRecord.TYPE_WORKBOOK: LOG.trace("loading excel data information complete."); break; case BOFRecord.TYPE_VB_MODULE: break; case BOFRecord.TYPE_WORKSHEET: int size = currentSheet.size(); if (size > 0) { if (currentSheet.get(size - 1).isEmpty()) { currentSheet.remove(size - 1); } } break; case BOFRecord.TYPE_CHART: break; case BOFRecord.TYPE_EXCEL_4_MACRO: break; case BOFRecord.TYPE_WORKSPACE_FILE: break; } break; default: if (record instanceof LastCellOfRowDummyRecord) { // remove empty row. if (!currentRow.isEmpty()) { int nullSize = 0; for (Object obj : currentRow) { if (obj == null) { nullSize += 1; } } // remove the row of all member is null if (nullSize == currentRow.size()) { currentRow.clear(); missingRows.get(sheetName).add(originalRowIndex); } else { LastCellOfRowDummyRecord lastCellOfRowDummyRecord = (LastCellOfRowDummyRecord) record; if (lastCellOfRowDummyRecord.getLastColumnNumber() > -1) { for (int i = currentRow.size(); i < maxColumnlength; i += 1) { missingCells.get(sheetName).add(new int[] {i, lastCellOfRowDummyRecord.getRow()}); currentRow.add(null); } } currentSheet.add(currentRow); currentRow = new ArrayList<Object>(); } } originalRowIndex += 1; } else if (record instanceof MissingCellDummyRecord) { MissingCellDummyRecord missingCellDummyRecord = (MissingCellDummyRecord) record; currentRow.add(null); missingCells .get(sheetName) .add(new int[] {missingCellDummyRecord.getColumn(), missingCellDummyRecord.getRow()}); } else if (record instanceof MissingRowDummyRecord) { MissingRowDummyRecord missingRowDummyRecord = (MissingRowDummyRecord) record; missingRows.get(sheetName).add(missingRowDummyRecord.getRowNumber()); } break; } }