mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
Fixed the bugs in the getRowsFromTable method, everything should be working as intended.
This commit is contained in:
parent
934fd0198c
commit
43fb8c8eba
@ -131,7 +131,7 @@ public class ExcelReader extends AbstractReader {
|
|||||||
//2. This also implies there is no way to determine if a workbook is empty,
|
//2. This also implies there is no way to determine if a workbook is empty,
|
||||||
//since a last row num of 0 doesnt differentiate between a record in 0 or
|
//since a last row num of 0 doesnt differentiate between a record in 0 or
|
||||||
//nothing in the workbook. Such a HSSF.
|
//nothing in the workbook. Such a HSSF.
|
||||||
return getRowsFromTable(tableName, 0, getRowCountFromTable(tableName) + 1);
|
return getRowsFromTable(tableName, 0, getRowCountFromTable(tableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,22 +158,29 @@ public class ExcelReader extends AbstractReader {
|
|||||||
Iterator<Row> sheetIter = workbook.getSheet(tableName).rowIterator();
|
Iterator<Row> sheetIter = workbook.getSheet(tableName).rowIterator();
|
||||||
List<Map<String, Object>> rowList = new ArrayList<>();
|
List<Map<String, Object>> rowList = new ArrayList<>();
|
||||||
|
|
||||||
int currRowCount = 0;
|
|
||||||
|
|
||||||
//Read the header value as the header may be a row of data in the
|
//Read the header value as the header may be a row of data in the
|
||||||
//excel sheet
|
//excel sheet
|
||||||
if(headerCache.containsKey(tableName)) {
|
if(headerCache.containsKey(tableName)) {
|
||||||
Row header = headerCache.get(tableName);
|
Row header = headerCache.get(tableName);
|
||||||
if(currRowCount++ >= offset) {
|
if(header.getRowNum() >= offset
|
||||||
|
&& header.getRowNum() < (offset + numRowsToRead)) {
|
||||||
rowList.add(getRowMap(tableName, header));
|
rowList.add(getRowMap(tableName, header));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(sheetIter.hasNext() && currRowCount < (offset + numRowsToRead)) {
|
while(sheetIter.hasNext()) {
|
||||||
Row currRow = sheetIter.next();
|
Row currRow = sheetIter.next();
|
||||||
if(currRowCount++ >= offset) {
|
//If the current row number is within the window of our row capture
|
||||||
|
if(currRow.getRowNum() >= offset
|
||||||
|
&& currRow.getRowNum() < (offset + numRowsToRead)) {
|
||||||
rowList.add(getRowMap(tableName, currRow));
|
rowList.add(getRowMap(tableName, currRow));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if current row number is equal to our upper bound
|
||||||
|
//of rows requested to be read.
|
||||||
|
if(currRow.getRowNum() >= (offset + numRowsToRead)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rowList;
|
return rowList;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user