Can you please let me know how to export jquery grid to excel. In the Media Items section there is a video which explains how to export to excel by calling the DB again. But i want to export the contents of the grid to excel. It will be great if some one can assist me on the same.
Regards,
Suresh A
Hi Suresh A,
Thank you for posting in the community.
The Infragistics Excel engine can be used to export the data bound to the igGrid to Excel. Currently there is no separate control for exporting our jQuery grid. You can find more information on the topic in the following discussion:
http://forums.infragistics.com/forums/p/64055/324125.aspx
Here is also a sample from our samples collection demonstrating the Infragistics Excel Framework:
http://samples.infragistics.com/jquery/infragistics-excel/create-excel-worksheet
Please feel free to contact me if you have any questions.
Please do not hesitate to contact me if you have any further questions regarding this scenario.
Hi Martin,
Thanks for your response.
So theres no othey way of doing this??? Like in normal GridView if we use Innerhtml then we can write the contents of the grid. Is there any other way to achieve the same functionality in iGrid as well?
Hello Suresh A,
Of course there are other ways to do this, but each of them has its pros and cons.
The pros of my proposal are that it is bandwidth friendly, but the cons is that it takes server memory for the cache.
Another solution is to send igGrid data source(For example plain HTML or JSON) back to the server for processing, but this means that client must upload a lot of data to the server.
About GridView. You can get igGrid Html with this jQuery API:
var gridHtml = $("#grid1").html();
P.S.: I'm not quite sure that I understood your last question. Do you want to skip posting back to the server when exporting to excel or you want to send grid html to server?
Sincerely,
Martin Pavlov
Infragistics, Inc.
I want to export grid html to excel.
As far as I know you cannot create file in excel format on client (browser), because there is automation involved in the process etc.
However you can create comma separated file(CSV), which excel can read. Here is Stackoverflow question on the subject:
http://stackoverflow.com/questions/4639372/export-to-csv-in-jquery
Look at the verified answer. There is mentioned "Downloadify" (which you can find here: https://github.com/dcneiner/Downloadify ). You can use it to save a file on the client i.e. popup file save dialog. You have to supply the content yourself by converting igGrid html data into comma separated text.
I haven't done this myself, so I cannot give you sample, but if you experience problems I can try to create one.
Hope this helps,
Martin Pavlov,
Files cannot be created directly on the client, without using a third party plugin such as Flash, ActiveX or Silverlight. This is a limitation in the way Javascript executes, and this is basically completely sandboxed. Moreover, even if you generate the binary file contents in JavaScript, by following the binary pattern in a string form (quite a lot of work in the first place), you won't be able to serve that file for download directly.
What you can do, though, is generate the file contents on the client, then POST to a URL, and have that URL serve the file to the client.
Download an Excel or any other file from a grid, is not possible without a request to a server, which would serve that file.
there is also a HTML5 API you may take a look at, but it's at an experimental stage:
http://dev.w3.org/2006/webapi/FileAPI/
http://www.w3.org/TR/file-writer-api/
at the moment, AFAIK, only Chrome and FF support this.
Hope it helps. Thanks,
Angel