Changeset 7676


Ignore:
Timestamp:
Mar 27, 2019, 9:58:57 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2161: Import data from Excel files

The FlatFileParser need to keep track of how many lines that has been parsed when switching worksheet in Excel mode or the mapping will not point to the correct row in the current sheet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/parser/FlatFileParser.java

    r7673 r7676  
    227227  */
    228228  private XlsxToCsvUtil.SheetInfo excelSheet;
     229 
     230  /**
     231    The value of the parsedLines when the current Excel sheet is parsed.
     232    Used to find the correct row number in the current sheet (=parsedLines - excelParsedLinesOffset)
     233   */
     234  private int excelParsedLinesOffset;
    229235 
    230236  /**
     
    858864              excelSheet = excelWorkbook.getSheetAsCsv(parsedSections);
    859865              excelSheetName = excelSheet.getName();
     866              excelParsedLinesOffset = parsedLines;
    860867            }
    861868            parsedSections++;
     
    14111418                excelSheet = excelWorkbook.getSheetAsCsv(parsedSections);
    14121419                excelSheetName = excelSheet.getName();
     1420                excelParsedLinesOffset = parsedLines;
    14131421              }
    14141422              parsedSections++;
     
    14411449              if (excelSheet != null)
    14421450              {
    1443                 nextData = new ExcelData(excelSheet, parsedLines, parsedDataLines, line, columns, emptyIsNull, nullIsNull);
     1451                nextData = new ExcelData(excelSheet, excelParsedLinesOffset, parsedLines, parsedDataLines, line, columns, emptyIsNull, nullIsNull);
    14441452              }
    14451453              else
     
    16541662              excelSheet = excelWorkbook.getSheetAsCsv(parsedSections);
    16551663              excelSheetName = excelSheet.getName();
     1664              excelParsedLinesOffset = parsedLines;
    16561665            }
    16571666            parsedSections++;
     
    20422051      Create a new data object.
    20432052    */
    2044     ExcelData(SheetInfo sheet, int lineNo, int dataLineNo, String line, String[] columns, boolean emptyIsNull, boolean nullIsNull)
     2053    ExcelData(SheetInfo sheet, int lineOffset, int lineNo, int dataLineNo, String line, String[] columns, boolean emptyIsNull, boolean nullIsNull)
    20452054    {
    20462055      super(lineNo, dataLineNo, line, columns, emptyIsNull, nullIsNull);
    20472056      this.sheet = sheet;
    2048       this.rowOffset = sheet.getFirstRow()-1;
     2057      this.rowOffset = sheet.getFirstRow()-1-lineOffset;
    20492058      this.colOffset = sheet.getFirstColumn();
    20502059    }
Note: See TracChangeset for help on using the changeset viewer.