Skip to content

getColumnNames(Sheet sheet) → UnsupportedOperationException: Getting row by index not supported when streaming. #115

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

Closed
adrian-pusty opened this issue Jul 30, 2023 · 1 comment · Fixed by #144

Comments

@adrian-pusty
Copy link

Is it expected behaviour that using StreamingXlsxItemReader with BeanWrapperRowMapper causes UnsupportedOperationException?

StreamingSheet throws (in method: getRow(int rowNumber)) this exception when we try to retrieve column names.

I have a sample code snippet that reproduces this issue: adrian-pusty@8c1f3ba#diff-e8b601a5301d162b2c94ad1fed7ab3dcc638bd4d49eed4dff61db1074ae3a037

I think that having "header" field in BeanWrapperRowMapper would solve the it:
adrian-pusty@a727c46#diff-0ac74f7f100e3eff66583af2aaf6350a51c3e650c198b699d1732da14fea0e71

@mdeinum
Copy link
Collaborator

mdeinum commented Sep 19, 2023

This is indeed expected behavior as the result must be processed streaming and not retrieved on a row basis.

The base class for the item readers pre-configures the DefaultRowSetFactory that is in use. The DefaultRowSetFactory uses the RowNumberColumnNameExtractor to extract the column names. Creating a DefaultRowSetFactory with a StaticColumnNameExtractor should prevent this error, as that has a static list of column names.

This might be a documentation issue to improve the sample we have in the README as I currently don't see a way around reading the first row from the streaming sheet, without impacting the the whole reading (the stream will have moved one row already, skewing the skiplines functionality).

@mdeinum mdeinum self-assigned this Aug 7, 2024
@mdeinum mdeinum added this to the spring-batch-excel-0.2 milestone Aug 7, 2024
mdeinum added a commit that referenced this issue Sep 18, 2024
Document on how to use the BeanWrapperRowMapper with the StreamingXlsxItemReader as that requires a bit more configuration due to the streaming nature.

Next to the documentation also added a test case for this to show how to configure it as well.

Closes: #115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants