I am using GWT with java. in my application i should upload excel file and should read the content of excel file and store data in entity. I have multiple columns in my excel sheet and i need to map them with my fields in the entity. please suggest me how to achieve this. for example : I have customer Names in excel sheet i need to save them in database/entity on click of button any help.
Asked
Active
Viewed 1,398 times
0
-
what have you tried so far? i would suggest a async call to the server with the excel content and then parse out everything you need – Manuel Jain Aug 07 '15 at 07:27
-
Manuel , I did not try anything because i am new in gwt so what are the possible ways to upload excel file and and how? and how can i read excel file data – Vijay Chougule Aug 07 '15 at 07:31
-
apache poi (https://poi.apache.org/) is a good choice to handle Microsoft documents on the server side. – El Hoss Aug 07 '15 at 09:16
2 Answers
0
For uploading a file you need a multipart upload form.GWT supports this with the FormPanel and the FileUpload widget.
If the server implementation is done in Java, you need an Servlet that handles the upload. Apache Commons Fileupload will help you handling the request. As mentioned above Apache POI can help parsing the Excel document.

Andreas Basler
- 131
- 3
-
Thank u Andreas i uploaded excel file in blobstore now i want access the excel file here FileInputStream file = new FileInputStream(new File(" what is the path here ")); what is path shall i procvide here.... I tried like this FileInputStream file = new FileInputStream(new File(pcash.getExceldata().getUrl())); but its threw exception Access Denied ....... – Vijay Chougule Aug 10 '15 at 05:56
-
Exception is : threw an unexpected exception: java.security.AccessControlException: access denied ("java.io.FilePermission" "/blobservice?blob-key=AMIflIl6DBDas.....xgtH7At" "read") – Vijay Chougule Aug 10 '15 at 06:56
0
You can upload excel file as any file. The detailed gwt example you can find here
http://www.celinio.net/techblog/?p=1207
To read from excel you have to use Apache POI
APIs for microsoft docs.
https://poi.apache.org/
You can use the following example to make yourself familiar with the excel api's

Community
- 1
- 1

Abhijith Nagaraja
- 3,370
- 6
- 27
- 55
-
Thank u Abhijith i uploaded excel file in blobstore now i want access the excel file here FileInputStream file = new FileInputStream(new File(" what is the path here ")); what is path shall i procvide here.... I tried like this FileInputStream file = new FileInputStream(new File(pcash.getExceldata().getUrl())); but its threw exception Access Denied ....... – Vijay Chougule Aug 10 '15 at 05:59
-
Exception is : threw an unexpected exception: java.security.AccessControlException: access denied ("java.io.FilePermission" "/blobservice?blob-key=AMIflIl6DBDas.....xgtH7At" "read") – Vijay Chougule Aug 10 '15 at 06:56
-
download the file from blobstore using down vote accepted Set it in header: public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { BlobKey blobKey = new BlobKey(req.getParameter("blob-key")); //example String filename = "someName.docx"; res.setHeader("Content-Disposition", "attachment; filename=\"" +fileName +\""); blobstoreService.serve(blobKey, res); } then read it using fileinputstream using the localpath – Abhijith Nagaraja Aug 10 '15 at 07:00
-
Thank u abhijith but in gwt we are not using request and response object. so how can i do it in gwt – Vijay Chougule Aug 10 '15 at 13:49
-
1you can use the request builder to do this http://www.gwtproject.org/javadoc/latest/com/google/gwt/http/client/RequestBuilder.html – Abhijith Nagaraja Aug 10 '15 at 21:31
-
Thank you so much Abhijith but i did not get that how to get excel file from blobstore and assign to FileInputStream . FileInputStream file = new FileInputStream(" "). could you please explain me in detail in gwt with code Thanks in Advance – Vijay Chougule Aug 11 '15 at 12:16