I am using ExtGWT. in my application i should accept excel file through browse button and should read the content of excel开发者_如何学Python file and display in a grid. please suggest me how to achieve this.
Thanks!
You will have to upload the excel document via a FileUploadField
- See: API and Example
On your server you will have to read the file and parse it via an external Excel API like one of those
- Java Excel API (only .xls files)
- Apache POI
Then you pass the result to your client as List<ModelData>
and display it on your editor grid.
Be careful about the fileupload because the file is not uploaded in the same way like your regular GXT forms.
As you can see in the example you need to specify an URL
for your form
panel.setAction("myurl");
The easiest way, would be to write a servlet for this action and process the file there like that with commons-fileupload
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List<FileItem> files = upload.parseRequest(request);
// process uploaded files
Uploading files via XMLHttpRequest
is unfortunately not supported by some browsers.
精彩评论