spring-projects / spring-batch-extensions

Spring Batch Extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mapping multiple sheets with multliple target objects

xscorpio972 opened this issue · comments

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

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?

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

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 notifications@github.com:

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)
.

Thank you, that you be great!

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

Would it be possible to fix this issue?

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

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

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?

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.

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.

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

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.

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.

Created new issue, thanks.

#95

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.

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.

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.

corrected the issue

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.