I'm working on Struts2 framework. I need to upload an excel file to the buffer so that I can extract its informations and print them into a table in a jsp page. I followed this tutorial : http://www.roseindia.net/struts/struts2/struts-2-file-upload.shtml , and so I could upload any type of file. My question is then : how can restrict the type into .xls and .xlsx ? and how can I get the content of the rows existing in the excel file? I read somewhere that i can use the Apache POI API ... but I couldn't get much how to do. Thank you.
Asked
Active
Viewed 3,845 times
2 Answers
1
Have you seen the Struts 2 File Upload Tutorial ?
It shows how to restrict to certain mime types.
You need the mime types described here for excel.
-
To add to this answer, the file type upload restrictions are set in the `struts.xml` config. Look at the tutorial linked by @VolkerK and look for ``. In addition to the mime types linked above, I posted MIME Types for Office 2010 formats in this answer: http://stackoverflow.com/a/10998727/727439 – nmc Jul 14 '12 at 14:12
0
There is an opensource library called jxl. After you haveuploaded your file to your server you can read it in and iterate through ght rows. Its very easy to do.

Spunog
- 309
- 3
- 11