Skip to content

feat: add support for column index limit in ReadSheet#942

Open
sapienza88 wants to merge 14 commits into
apache:mainfrom
sapienza88:column_support
Open

feat: add support for column index limit in ReadSheet#942
sapienza88 wants to merge 14 commits into
apache:mainfrom
sapienza88:column_support

Conversation

@sapienza88

@sapienza88 sapienza88 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

This PR is for adding support for reading a sheet based on rows AND columns index.
Added the feature in the Sheet module and unit tests

@delei

delei commented Jul 5, 2026

Copy link
Copy Markdown
Member

Welcome to participate in open source contributions.

Please refer to the contribution guide, complete your PR content and modify the commit message format, and provide the unit test code.

@delei delei added the PR: first-time contributor first-time contributor label Jul 5, 2026
@bengbengbalabalabeng

Copy link
Copy Markdown
Contributor

Please refer to the code contribution. Make sure the changes can be compiled and are properly formatted :)

@sapienza88

Copy link
Copy Markdown
Contributor Author

Please refer to the code contribution. Make sure the changes can be compiled and are properly formatted :)

No I cannot make sure it compiles on CI, maybe locally but not on CI

@bengbengbalabalabeng

Copy link
Copy Markdown
Contributor

No I cannot make sure it compiles on CI, maybe locally but not on CI

To prevent CI from being blocked by formatting or compilation issues, you can first run mvn clean install -DskipTests and mvn spotless:apply locally to ensure that both the build and formatting pass.

Please refer to the code contribution.

@delei

delei commented Jul 5, 2026

Copy link
Copy Markdown
Member

No I cannot make sure it compiles on CI, maybe locally but not on CI

Hi, may I ask if this is a draft PR?

I haven't seen any complete implementation logic for this new parameter, and there are no use cases of reading Excel files in the unit test code either.

@sapienza88

sapienza88 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

No I cannot make sure it compiles on CI, maybe locally but not on CI

Hi, may I ask if this is a draft PR?

I haven't seen any complete implementation logic for this new parameter, and there are no use cases of reading Excel files in the unit test code either.

not a draft PR, i will extend it to add a complete implementation logic for the new parameter, as well as a test based on reading dummy data.

But also it depends what do you mean by "complete implementation logic"?

@delei

delei commented Jul 5, 2026

Copy link
Copy Markdown
Member

not a draft PR, i will extend it to add a complete implementation logic for the new parameter, as well as a test based on reading dummy data.

It's okay. Please continue to develop and refine this PR, and conduct unit tests in the local environment. When a PR is ready for code review by community members, you can leave a message to let us know.

@delei delei added the PR: developing This feature will be added in future releases label Jul 5, 2026
@sapienza88

sapienza88 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@delei @bengbengbalabalabeng my understanding is that fesod does not support reading a sheet by column (only by rows) but it can write to a square set of cells, is that correct? where this logic of the this PR should also be propagated? which classes are also concerned with reading with a column index?
PS: I added some tests here.

@delei

delei commented Jul 9, 2026

Copy link
Copy Markdown
Member

my understanding is that fesod does not support reading a sheet by column (only by rows) but it can write to a square set of cells, is that correct? where this logic of the this PR should also be propagated? which classes are also concerned with reading with a column index? PS: I added some tests here.

Reading and converting the data in cells is achieved through the ReadListener interface. Please refer to this method to see if it provides any inspiration or assistance to you.

BTW, I'm a little worried about this PR. Could you please start the preliminary discussion in the issue and provide your proposed solution? (e.g. #941 )

I didn't mean any offense, the other members of the community generally do not discuss proposals in the PR. This would help save the time for the code review.

@sapienza88

sapienza88 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

my understanding is that fesod does not support reading a sheet by column (only by rows) but it can write to a square set of cells, is that correct? where this logic of the this PR should also be propagated? which classes are also concerned with reading with a column index? PS: I added some tests here.

Reading and converting the data in cells is achieved through the ReadListener interface. Please refer to this method to see if it provides any inspiration or assistance to you.

BTW, I'm a little worried about this PR. Could you please start the preliminary discussion in the issue and provide your proposed solution? (e.g. #941 )

I didn't mean any offense, the other members of the community generally do not discuss proposals in the PR. This would help save the time for the code review.

@delei I meant not "in n cells" but in rows AND columns. And not a listnener function. That was a severe limitation of fesod thankfully this PR comes to the rescue, the idea is clear and simple (read a sheet by rows and columns) i think there is no need to describe it more

@sapienza88

Copy link
Copy Markdown
Contributor Author

@delei can you review the pr?

@delei

delei commented Jul 9, 2026

Copy link
Copy Markdown
Member

can you review the pr?

Please fix the errors identified in the CI and ensure that the CI can pass successfully.

Assertions.assertNotNull(readResults);
Map<Integer, String> parsedRow = readResults.get(0);
Assertions.assertEquals("1", parsedRow.get(0));
Assertions.assertEquals("Alice", parsedRow.get(1));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List<Integer> targetColumns = Arrays.asList(0, 2);

The targetColumns variable has been set to only include columns 0 and 2, why are there three columns of data in the result?

Is there any misunderstanding or unfinished code logic?

@sapienza88 sapienza88 Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will correct, i wrongly thought that it is from to

@delei delei Jul 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to know what features you have implemented through this PR.

Is it the case that the readResults variable only contains data from these two columns?

Assertions.assertEquals(2,parsedRow.size());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes thats correct

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delei fixed now

@sapienza88 sapienza88 Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delei fixed!

@delei delei Jul 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we continue to develop it so that it can support xls files at the same time?

@sapienza88 sapienza88 Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delei I will do that in a separate PR, pls merge this xlsx work first

@delei delei Jul 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your willingness to continue contributing to open source.

IMO, due to the introduction of new parameters, I hope this is a complete PR that includes all the features, making it easier for community members to understand this parameter.

You can also continue to submit new PR to add documentation for this parameter, optimize the code, or fix minor errors.

@sapienza88 sapienza88 Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delei sure I will add docs as well for this (in a separate PR), thanks

@delei delei changed the title Add support for column index limit in ReadSheet feat: add support for column index limit in ReadSheet Jul 12, 2026
@sapienza88

sapienza88 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@delei are we done here? can you merge this (with the associated docs: #949)

@delei delei left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

BTW, currently, only xlsx files are supported.

@delei delei removed the PR: developing This feature will be added in future releases label Jul 15, 2026
@sapienza88

sapienza88 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

LGTM.

BTW, currently, only xlsx files are supported.

@delei yes

Comment on lines +138 to +139
List<Integer> includeColumnIndexes = null;
if (xlsxReadContext.readSheetHolder() != null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null checks for xlsxReadContext.readSheetHolder() and getReadSheet() seem unnecessary here, The ReadSheetHolder is always initialized in

if (readSheet != null) {
try {
xlsxReadContext.currentSheet(readSheet);

Additionally, the filtering logic for columns can be moved to the beginning of the endElement method. For columns not in includeColumnIndexes, the corresponding ReadCellData instances do not need to be assigned.

this.sheetName = sheetName;
this.numRows = numRows;
this.columnIndexes = columnIndexes;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the numCols parameter is not used.
  • this.columnIndexes = columnIndexes; assigns the field to itself.

/**
* The number of columns to read, the default is all, start with 0.
*/
private Integer numColumns;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numColumns field is not used in the current change. Could you check whether this is intended?

.sheetNoIfNotNull(sheetNo)
.sheetNameIfNotNull(sheetName)
.numRowsIfNotNull(numRows)
.includeColumnIndexes(columnIndexes);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it more appropriate to replace includeColumnIndexes with includeColumnIndexesIfNotNull?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: first-time contributor first-time contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants