Exporting A Flex DataGrid To Excel
Posted By : todd sharp Posted At : January 24, 2007 12:36 PM Posted In: Flex, Flash Forms, ColdFusion
5
This is easily found via Google, but it's pretty cool nonetheless. There's a cool example up on CFLEX.NET that shows an implementation of exporting the contents of a Flex DataGrid to Excel. Essentially the script loops over the grid and creates an HTML table from the contents. The script then sets that table (in the form of a string) to the users clipboard and calls a JS function in the calling page to open an Excel workbook and paste the contents of the system clipboard to the new workbook (or fails to an alert which tells the user their clipboard is set). This implementation is specific to Flex 1.5 I believe - but there is a comment posted to the example with a 2.0 version. I've used this technique successfully on smaller grids - anything too large will crash Flash Player.
My most recent use of this was on a grid that was guaranteed to contain small results (no more then 50 rows, 20 cols). I did make a minor change to the script to have the doCopy() function return the string rather then set it to the clipboard. My next step was to pass the string via getURL() to a ColdFusion template which served the string up in Excel with CFCONTENT.
If you're new to Flex you should definitely keep your eye on CFLEX.net - it's a really good resource run by Tariq Ahmed.



http://www.psalterego.com/2006/05/17/parsing-excel...
http://dev.psalterego.com/xls/ExcelParser2.html (click DataGrid at the bottom)
http://www.erotikciler.com
http://kathrynrosales.tripod.com
http://dexterclary.tripod.com
http://hugohoelscher.tripod.com
http://riichardrankin.tripod.com