Converting Flex 3 Datagrid to Excel Sheet
ColdFusion , Flex , CFC - Author:John Gag at 6:00 PM Add commentsI was posed with the problem of converting flex 3 datagrids from a dashboard to an excel sheet. I came across some really good blog posts that explain how to accomplish this task. The best one can be found here.
The person has it set up in actionscript calling a .php page but I wanted to supply the simple ColdFusion code for us ColdFusion nerds. All you need to do is direct the actionscript to a coldfusion page containing the code below and it should work.
<cfcontent type=”application/msexcel”>
<cfheader name=”Content-Disposition” value=”filename=export.xls”>
<cfoutput>
#form.htmltable#
</cfoutput>
This little flex 3 script makes lots of managers very happy! My next adventure will be printing flex 3 datagrids and graphs into a nice looking report which seems to be posing a little challenge for me, the nice looking part that is ;)






Sep 19, 2008 at 6:26 PM Will this work on advanced data grids as well?
Sep 19, 2008 at 6:27 PM No, I could not find a solution for that. I would love to know a link or the solution if someone has it.
Jan 26, 2009 at 5:13 PM I was able to get it to work correctly for an AdvancedDataGrid just by changing the two functions to accept an AdvancedDataGrid instead of a DataGrid. The only issue I ran into was exporting formatted dates. I am working on that now.
Jan 26, 2009 at 7:06 PM @CrazyBee - Yeah I got the AdvancedDataGrid to work also. Let me know if you get the date formatting to work. Thanks!
Feb 16, 2009 at 5:16 PM I am having the same issue my advanceddatagrid has Grouped data styleFunction and ItemRenderers No errors just no excel...Ideas?
Feb 26, 2009 at 2:21 PM Any updates on the Flex 3 AdvancedDataGrid implementation for this component...I used a workaround passing in the ArrayCOllection...But now would like to re visit the excel Export section...I think the issue I encountered is related to grouping that I have done...Is there anyone with experience related to grouping collections/Advanced datagrids and exporting to Excel out there...I cannot find any posts on this on the web
May 7, 2009 at 6:45 PM Did anyone figure out how to get date formatting to work for the export?
Jun 12, 2009 at 2:19 PM Hello did you resolve the code for AdvancedDataGrid. Could we have the code???? thanks a lot
Jun 16, 2009 at 11:11 AM @Garra - You could simple change the functions to accept advanceddatagrid instead of just datagrid. Hopefully I will get the time to write a component for exporting info into excel.
Jun 21, 2009 at 10:40 PM How do I export without installing ColdFussion? I am using BlazeDS on Tomcat with Spring and Hibernate storing data in MySQL. Thanks.
Sep 21, 2009 at 4:04 PM By changing DataGrid to AdvancedDataGrid as input parameter I get the following error msg: "Property getItemAt not found on mx.collections.HierarchicalCollectionView and there is no default value." I think the error occurs on this line: if(dg.dataProvider.getItemAt(j) != undefined && dg.dataProvider.getItemAt(j) != null) { any advise!