简体   繁体   中英

How to export excel file in GWT?

My requirement is to export an excel from GWT application on click of export button. In my case There is no need to send data from client to server as I can directly obtain data from database(same data is being populated on the client that is being exported). All I tried to send a RPC call from Client site . but I am not able to figure out how to export excel on receiving the RPC call at server site.

There is no way generating a excel file on the client site with native GWT without adding a third party product. (see knarf answer below)

I personally prefer this solution:

  • open an new window on the client

  • use a url, that triggers a servlet on the server

  • let the server generate the excel file

  • save the newly generated file inside the webspace

  • return the url to the excel file to the client

This works for me.

This is certainly possilbe 100% client side.

You can use an Excel JavaScript builder like https://github.com/stephenliberty/excel-builder.js and call it from GWT with jsni or jsinterop.

Later you can save the file by

Note for the generating an Excem file you could also just create an html file with table tags and save it as .xls, it with filesaver.js.

I use the html solution and filesaver.js/html5 download in my project and this works without a problem, and without the need for any serverside code, or any plugin on the client. 100% HTML5/javascript.

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