简体   繁体   中英

Where should the code to read data from an xlsx file be placed in a web project?

I have a web project which has the same as in a typical web project, say web, dto, service, dao. Now I'm working with the service layer. Now, I want to read an xls file and each row should be pushed to the db via dao. I have created a separate utility class to read the xls file. To which layer, the logic of reading should go? Should it be kept in the web itself and after reading it from the web, a list should be created and passed on to the service layer? Is this approach correct? Any advice?

Having the logic of reading the excel file in the service layer is fine. I am assuming that the excel file will be received when a user uploads a file in the web app. If you have a controller, then delegate the reading of the excel file to the service from the controller and then delegate the persistence to the dao layer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM