Converting Flex 3 Datagrid to Excel Sheet

ColdFusion , Flex , CFC - Author:John Gag at 6:00 PM Add comments

I 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  ;)

11 responses to “Converting Flex 3 Datagrid to Excel Sheet”

  1. Brian Says:
    Will this work on advanced data grids as well?
  2. John Gag Says:
    No, I could not find a solution for that. I would love to know a link or the solution if someone has it.
  3. CrazyBee Says:
    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.
  4. John Gag Says:
    @CrazyBee - Yeah I got the AdvancedDataGrid to work also. Let me know if you get the date formatting to work. Thanks!
  5. wpageiii Says:
    I am having the same issue my advanceddatagrid has Grouped data styleFunction and ItemRenderers No errors just no excel...Ideas?
  6. wpageiii Says:
    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
  7. Ozzway Says:
    Did anyone figure out how to get date formatting to work for the export?
  8. Garra Says:
    Hello did you resolve the code for AdvancedDataGrid. Could we have the code???? thanks a lot
  9. John Gag Says:
    @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.
  10. Joshua Says:
    How do I export without installing ColdFussion? I am using BlazeDS on Tomcat with Spring and Hibernate storing data in MySQL. Thanks.
  11. sg Says:
    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!

Leave a Reply

Leave this field empty:



Powered by Mango Blog. Design and Icons by N.Design Studio