With the latest release of jQWidgets, we enhanced the jqxGrid widget by adding new data exporting capabilities. Let’s see what’s necessary to export the grid’s data to excel.
In order to use the Export to Excel feature, you need to load two additional Javascript files.
<script type="text/javascript" src="../../jqwidgets/jqxdata.export.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.export.js"></script>
To export the Grid’s data to Excel and save it in a file, you need to call the ‘exportdata’ method with two parameters – the data format(‘xls’) and the file’s name.
$("#jqxgrid").jqxGrid('exportdata', 'xls', 'jqxGrid');
Online Demo:
http://jsfiddle.net/jqwidgets/6HRU8
I work in an OpenOffice based environment. When I downloaded the XLS file and opened it in OpenOffice, it came back with an empty grid. Surprised, I tried the one machine we have which has Excel 2010, and got the message:
“The file you are trying to open, ‘jqxGrid.xls’, is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?”
Looking at the file directly it seems to be a raw XML file rather than being an XLS file. Is this what you expect?
The Export to Excel works with the ExcelML format which is a valid Excel format. You can read more about ExcelML here: http://blogs.msdn.com/b/brian_jones/archive/2005/06/27/433152.aspx
Yes, it is in a valid format (thanks for the info). But surely you should be concerned if one product (OpenOffice) just displays nothing and the other product (Excel 2010) pops up a nasty warning saying the file you’ve downloaded might be suspicious? I’m certainly concerned by that.