Exporting A Flex DataGrid To Excel

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.



Comments
The cooler behavior is the other way around - reading a .xls file and displaying it in a Flex 2 datagrid:

http://www.psalterego.com/2006/05/17/parsing-excel...
http://dev.psalterego.com/xls/ExcelParser2.html (click DataGrid at the bottom)
# Posted By darron | 1/24/07 2:07 PM
Damn - that IS very cool. How come I never saw any of this on the aggregators???
# Posted By todd sharp | 1/24/07 2:20 PM
# Posted By seks | 4/4/08 2:50 PM
Thanks for helping with EXcel
# Posted By YAEL NAIM | 8/25/08 5:19 AM

Calendar

Sun Mon Tue Wed Thu Fri Sat
   1234
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Subscribe

Enter your email address to subscribe to this blog.

Tags

actionscript ajax blogging cfsnippets coldfusion flash forms flex funny stuff javascript misc model-glue off topic personal project learn slidesix sql

Recent Comments

Chinese Birth Calendar Accuracy Test
mama to be said: ok so i will be 2 months shy of 18 when i have my baby. this calendar does not technically work for ... [More]

Fixing 'User Profile Service Failed The Logon' on Vista
Mike said: That fix worked although all i did was remove .bak and reset state to 0. User was able to log in to... [More]

Chinese Birth Calendar Accuracy Test
Melissa said: Wrong for my daughter, which it predicted to be a boy... we'll see for #2. Predicts a girl (maybe, f... [More]

Adding Auto Generated Code Downloads to BlogCFC
fweerw said: http://www.ibiblio.org/st... http://www.cambodia.ait.a...... [More]

Check Out The New SlideSix
Todd Sharp said: Thanks for the feedback Ben & Rachel! I'll keep it all in mind as I tweak things over the next ... [More]

RSS


adobe community experts

coldfusionbloggers

FullAsAGoog MXNA

Consumed By Feed-Squirrel.com