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

Calendar

Sun Mon Tue Wed Thu Fri Sat
     12
3 4 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 misc model-glue off topic personal project learn slidesix sql

Recent Comments

ColdFusion/Sharepoint Integration - Part 1 - Authenticating
todd sharp said: Jenn: Check your email. Todd [More]

ColdFusion/Sharepoint Integration - Part 1 - Authenticating
Jenn said: When does the next issue of FAQU come out? For that matter is it at all possible to get a preview o... [More]

A Major Milestone In My Marriage
Brian Meloche said: I converted my wife last year. That said, I find Firefox 3 a bit crashy. [More]

SlideSix Gets PDF Support
todd sharp said: Do you mean add numbering to the PDF output? If so, yeah, that would be easy. Just to be clear tho... [More]

SlideSix Gets PDF Support
salvatore fusto said: nice work Todd, but can you add slide numbering: 1/N, 2 of N and so long? it would be useful. regard... [More]

RSS


coldfusionbloggers

FullAsAGoog MXNA

Consumed By Feed-Squirrel.com