Search code examples
jqueryjqgridfree-jqgrid

Free jqGrid 4.8.0 - Is there a plugin for export to csv


I saw some examples for csv export, but want to know if there is something built-in that knows to export based on the postData that is in active, the only example I see are for local data.


Solution

  • Depend on the options used in jqGrid it can hold only the page of formatted data. To export to Excel or CSV one need probably full dataset of original data. One more problem is in saving the results of exporting or with opening it with the correct program. I mean that the user expect typically to be able to save/to open .Xlsx-file with the data on click on the "Export" button. The most clear and simple way to implement this would be the solution on the server side. One can set Content-Type and content-disposition headers in HTTP response which make the user comfortable to open the results.

    I've seen different implementation of exporting to Excel. The simplest one consist from creating HTML results under the wrong name. In my opinion the most clean way is the usage of OpenXML SDK, which you can download here. The SDK is available on GitHub too (see here).

    I recommend to read the answer and this one where I posted the code which I used myself.