what i need now is to generate it to excel
Say, after user filter the data s/he wants, click "Export to Excel"
button, and .xls is generated exactly like what is in the grid (after
filtering)
Could someone help providing sample script?
Provided here is the script for PHP / Java / ASP.NET :
This is Paul from DHTMLX. We might add the export script for Ruby on
Rails in the future. As for now, you can try to use the online export
service. Check this blog post: Grid to PDF and Excel Online Service - DHTMLX Blog
I’m not familiar with dhtmlx, but you can send_data the html table to an .xls file with the excel mime-type and Excel will read it in - formatting should stay intact - although I don’t know what limitations on formatting may exist. Works with UTF-8 characters, too. OpenOffice will grok it - other spreadsheet apps don’t seem to like it, though.
There’s a spreadsheet gem that will give you more fine grained control (in exchange for more work) over the .xls file, and produces a legit .xls file, which matters if you want to support more spreadsheet programs than just Excel.
I’ve also seen XML Doc approaches. Search to_xls and you should find a few different options.