I updated the “AIR 2 Excel” sample application for the official AIR 2 launch. “AIR 2 Excel” demonstrates different techniques for AIR/Excel integration, including the new AIR 2 File.openWithDefaultApplication() API.
In Adobe AIR 1.0 and 1.5, there were different options to “open” the data of a Flex DataGrid in Excel. For example, you could leverage the AIR native drag-and-drop support to drag rows from the DataGrid to an open Excel spreadsheet. You could also drag rows to the desktop (or anywhere on the file system) as an .xls file. These two approaches are demonstrated in my Salesbuilder sample application. Another approach was to use a server roundtrip to download the generated .xls file from the server and force Excel to open with the data.
There was however no immediate way to implement a straight (client-side only) “Open in Excel” feature (aka click a button to open your DataGrid data in Excel). With AIR 2.0 and the new File.openWithDefaultApplication() method this becomes extremely easy to implement. In the sample below, I provide an example of this new feature. The sample also supports the drag-and-drop approach from the AIR application to Excel and from the AIR application to the desktop (or anywhere else on the file system). This sample uses the as3xls library to create the Excel spreadsheet. View Source is enabled.
Make sure you have the AIR 2 runtime installed (you can download the AIR 2 runtime here), and install the application using the badge below:
[airbadge]AIR 2 Excel, http://coenraets.org/AIR2Excel/AIR2Excel.air, 2.0, http://coenraets.org/AIR2Excel/AIR2Excel.png[/airbadge]
View Source (right click) is enabled.
NOTE: You can download the AIR 2 SDK here.