Write to different Sheets in a single excel file from multiple tables

给你一囗甜甜゛ 提交于 2019-12-13 22:12:20

问题


Can someone please give me a technical design overview of how I should implement this scenario :

I am using spring batch to import data from CSV files to different tables and once they are imported I run some validations on these tables and now I need to write all those data from 3 different tables into three different Sheets of a single Excel file. Can someone please help me how I should use ItemReaders and Itemwriters to solve this problem ?


回答1:


If I'm asked I would implement as follows. create xls file from your code or first step which would be method invoker. which would create the file. and pass the file job parameters.

  1. Step 1/2 would do a chunk reading from table 1 and in the itemwriter I would use the custom Item writer which would use POI and I would write to first sheet.
  2. Step 2 would do a chunk reading from table 2 and in the itemwriter would read second sheet.

Since you have single file you can never achieve the advantage of spring batch performance like multithread, partitioning etc. Rather than its better to write to different file with independent task



来源:https://stackoverflow.com/questions/20076810/write-to-different-sheets-in-a-single-excel-file-from-multiple-tables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!