Skip to content
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

Mapping multiple sheets with multliple target objects #17

Closed
xscorpio972 opened this issue Apr 25, 2015 · 20 comments
Closed

Mapping multiple sheets with multliple target objects #17

xscorpio972 opened this issue Apr 25, 2015 · 20 comments

Comments

@xscorpio972
Copy link

A workbook with differents sheets can't be read if the objects targets aren't the same type.

@mminella
Copy link
Member

mminella commented Jun 8, 2015

I left a note in the PR, but we can continue design discussions here. Instead of creating a whole new reader, why not take the approach of a decorator like the MultiResourceItemReader?

@MichelinMan
Copy link

We have a use case for exactly this scenario. Is there a chance that the pull request for the proposed solution could be merged? Many thanks

@xscorpio972
Copy link
Author

Hello,

I didn't have time to implement the solution with the decorator.
I'll try to do it the next week, is it ok?

Thanks

2015-06-25 19:53 GMT+02:00 MichelinMan [email protected]:

We have a use case for exactly this scenario. Is there a chance that the
pull request for the proposed solution could be merged? Many thanks


Reply to this email directly or view it on GitHub
#17 (comment)
.

@MichelinMan
Copy link

Thank you, that you be great!

xscorpio972 added a commit to xscorpio972/spring-batch-extensions that referenced this issue Jul 2, 2015
@almex
Copy link

almex commented Sep 21, 2015

I've already created my own implementation using Apache POI following the same idea you're exposing here :
https://github.com/almex/Raildelays/blob/master/batch/src/main/java/org/springframework/batch/item/file/ExcelSheetItemReader.java

@Anbarasan93
Copy link

Would it be possible to fix this issue?

@Karthick-Shanmugam-15
Copy link

i am facing issue with rowmapper. how to use rowmapper.

@ahmedmokhtar97
Copy link

i'm facing this issue right now and found out that there's a PR opened with a solution for it since 2015,
so i was wondering when will it could be merged ?
thank you in advance
@benas

@TechGrizzlee
Copy link

TechGrizzlee commented Feb 3, 2022

I've already created my own implementation using Apache POI following the same idea you're exposing here : https://github.com/almex/Raildelays/blob/master/batch/src/main/java/org/springframework/batch/item/file/ExcelSheetItemReader.java

We have tried to use your package and it's very helpful. Just not able to know how you can include a custom RowMapper. I see you have developed a be.raildelays.batch.bean.BatchExcelRowMapper to use ExchelSheetItemReader.

Is there any generic approach like org.springframework.batch.item.excel.mapping.BeanWrapperRowMapper where we can setTargetType as custom Model?

@mdeinum
Copy link
Collaborator

mdeinum commented Feb 3, 2022

Please don't use the Spring Batch Excel issues to discuss features in a different library. Either take that to that github repository or ask for feature improvements here.

@Kyeiv
Copy link

Kyeiv commented Apr 12, 2022

Hello, I don't know where to address this issue but thsi thread seems to be suitable. How is the work going with handling multiple excel sheets differently? I have noticed that this library's reader reads sheet for sheet, row by row.

@mdeinum
Copy link
Collaborator

mdeinum commented Apr 12, 2022

It doesn't. Configure a different reader per sheet you want to read and limit the reading of rows/sheets for that reader.

@Kyeiv
Copy link

Kyeiv commented Apr 12, 2022

Could you provide some more information how to do it? I am really sorry for that question, but i am new to spring batch. I know it isn't a place for such discussion so if you'd be so kind and write to me via email that is given in my description.

@mdeinum
Copy link
Collaborator

mdeinum commented Apr 12, 2022

What I proposed is currently not possible, as we read the whole thing starting from sheet 1. We would need to enhance the readers to include something to specify which sheets to read. However, how should one specify this? A list if numbers to include, a range, a combination or something else? While it might seem easy it might not be as easy as it is at a first glance.

Currently the main usecase for Spring Batch Excel is reading a single sheet excel file, 1 file with multiple sheets isn't done that often (hence no mapping per sheet etc. will exist).

But if you want to have a way of specifying what to read, please open a new ticket for that so that we could make the configuration work to read the file multiple times with different mappings.

@Kyeiv
Copy link

Kyeiv commented Apr 12, 2022

Created new issue, thanks.

#95

@mdeinum
Copy link
Collaborator

mdeinum commented Apr 12, 2022

You created an issue for multiple sheets not reading a specific sheet(s).

As it is a niche to have 1 file with multiple sheets and mapped to different objects I'm not willing to implement that in the readers. As it also yields other issues with building steps etc.

@Kyeiv
Copy link

Kyeiv commented Apr 12, 2022

You created an issue for multiple sheets not reading a specific sheet(s).

The issue title states "Need of reading one particular sheet or define mapping for every sheet". So I am aiming to read one sheet from the file for example passing ts name as parameter.

@mdeinum
Copy link
Collaborator

mdeinum commented Apr 12, 2022

The issue is an or :). The latter we already concluded isn't going to happen. So the only thing is to read a particular sheet or sheets. Not sure if that should be by name or index, that is for another discussion.

@Kyeiv
Copy link

Kyeiv commented Apr 12, 2022

corrected the issue

@mdeinum
Copy link
Collaborator

mdeinum commented Oct 2, 2023

The intent of the Excel readers is to map 1 row to 1 object. Trying to shoehorn this into 1 reader feels like adding much complexity for a niche functionality. For reading a file with multiple sheets you can use multiple steps and re-use parts of the configuration.

@mdeinum mdeinum closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests