Copy to Excel from Flex
Posted by Rusty Weneck in Uncategorized, tags: Computer Science, Excel, Flash, FlexI’ve promIsed my next article would be on Spring 3, as part 3 in my series on the web application. However, I’m going to take a little segway to a neat solution I’ve come up with for a common requirement that is a little tricky to solve. Copying data out of a data grid and being able to paste that data into Microsoft’s Excel.
Flex is often used for displaying and calculating many different metrics. Sometimes a new metric, or a one off request will come in to see the data in a slightly different way or with an additional calculation. A lot of times the one off requests don’t illicit a development investment to get the new analytic. Others might be too much of an immediate need and a development cycle would take too long. For this the ability to export the data to a less than friendly(IMHO), but standard and well know tool is a huge plus. Enter stage left…. Copy to Excel.
Copy the entire contents of the grids (both AdvancedDataGrid and DataGrid are supported, I wish these implemented a common interface) by not selecting any rows, or just the selected rows by selecting them (use shift or ctrl with click to multi select/deselect). This will call a static method in a util class (source available) that takes a single parameter, the grid itself. All data conversion from its dataProvider is handled, along with a header row with the headerText and if any of the fields use a labelFunction, that too is called to formate the data.
This is released under the MIT License, and is free for anyone to use/modify/distribute as they see fit. Just give props back here somewhere in the source.



Entries (RSS)