-
Notifications
You must be signed in to change notification settings - Fork 508
feat: add support for column index limit in ReadSheet #942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cfdb817
f907ae1
12ac741
6e5f7ec
2f71ecf
a466b1e
3b532dd
2480a2e
da29379
3af1b47
bee9c90
1c5da7b
a70c56c
e6869c3
fa2c984
cbd1291
6379674
d4176b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| package org.apache.fesod.sheet.analysis.v07.handlers; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.List; | ||
| import org.apache.fesod.common.util.BooleanUtils; | ||
| import org.apache.fesod.common.util.PositionUtils; | ||
| import org.apache.fesod.common.util.StringUtils; | ||
|
|
@@ -81,6 +82,22 @@ public void startElement(XlsxReadContext xlsxReadContext, String name, Attribute | |
| public void endElement(XlsxReadContext xlsxReadContext, String name) { | ||
| XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder(); | ||
| ReadCellData<?> tempCellData = xlsxReadSheetHolder.getTempCellData(); | ||
| int targetColumnIndex = 0; | ||
|
|
||
| List<Integer> includeColumnIndexes = | ||
| xlsxReadContext.readSheetHolder().getReadSheet().getColumnIndexes(); | ||
|
|
||
| if (includeColumnIndexes == null) { | ||
| targetColumnIndex = xlsxReadSheetHolder.getColumnIndex(); | ||
| } else { | ||
| // if it's a target column, rewrite the cell's internal index | ||
| targetColumnIndex = includeColumnIndexes.indexOf(xlsxReadSheetHolder.getColumnIndex()); | ||
| if (targetColumnIndex < 0) { | ||
|
|
||
| return; | ||
| } | ||
| } | ||
|
|
||
| StringBuilder tempData = xlsxReadSheetHolder.getTempData(); | ||
| String tempDataString = tempData.toString(); | ||
| CellDataTypeEnum oldType = tempCellData.getType(); | ||
|
|
@@ -130,10 +147,9 @@ public void endElement(XlsxReadContext xlsxReadContext, String name) { | |
| tempCellData.setStringValue(tempCellData.getStringValue().trim()); | ||
| } | ||
| } | ||
|
|
||
| tempCellData.checkEmpty(); | ||
| tempCellData.setRowIndex(xlsxReadSheetHolder.getRowIndex()); | ||
| tempCellData.setColumnIndex(xlsxReadSheetHolder.getColumnIndex()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Considering the earlier logic, assigning
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. targetColumnIndex is assigned in an if clause, so it would not make sense to assign here for all cases.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion, my previous comment might not have been clear enough. Here is what I actually meant: // ...
if (includeColumnIndexes == null) {
targetColumnIndex = xlsxReadSheetHolder.getColumnIndex();
} else {
// If it's a target column, rewrite the cell's internal index and pack it sequentially
targetColumnIndex = includeColumnIndexes.indexOf(xlsxReadSheetHolder.getColumnIndex());
if (targetColumnIndex < 0) {
return;
}
}
// ...
// line: 136 (old 154)
tempCellData.setColumnIndex(targetColumnIndex);Since we guarantee
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is correct and more readable.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bengbengbalabalabeng the refactoring has been implemented now, you can merge this PR as well as this related passing test: #945
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the previous version, when I want to confirm whether this change is intentional. Would you mind clarifying the expected behavior here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I must have overlooked this, now it is changed as it was in the previous correct version. |
||
| xlsxReadSheetHolder.getCellMap().put(xlsxReadSheetHolder.getColumnIndex(), tempCellData); | ||
| tempCellData.setColumnIndex(targetColumnIndex); | ||
| xlsxReadSheetHolder.getCellMap().put(targetColumnIndex, tempCellData); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.