PDA

View Full Version : Exporting to Excel from DataGrid


Rod F
03-12-2008, 09:58 PM
Hi!

I am working on a project that consist on reading XML values from a remote device and displaying them on a Flash interface. Flash takes the role of a 'digestor' of this data, if you will, in order to display it nicely and in a more orderly fashion thanks to the DataGrid component.

What I need to do after I have this data is to be able to export it as a .CSV or an .XLS file so I can view it in MS Excel or other spreadsheet programs. My problem lies here since I have no idea on how Flash can generate a file of such filetypes. I've read around the web that this can be achieved with a Flex routine and HTML. However I do not have Flex. Im interested in achieving something like what the MochiAds Dashboard can do.. I can see the data in flash and whenever I feel like it I click on Export to Excel and a .csv will be generated and downloaded into my computer for my viewing commodity.

Any ideas?

CyanBlue
03-13-2008, 02:15 PM
Howdy and Welcome... :)

Flash is not capable of generating any file by itself... Flash needs to send the data to the server side script that can then generate a file with the passed data...

Rod F
03-13-2008, 08:55 PM
Howdy and Welcome... :)

Flash is not capable of generating any file by itself... Flash needs to send the data to the server side script that can then generate a file with the passed data...

Ok, thanks

So, considering that I am using an external device to which I cannot upload any files like PHP capabilities for example... And also considering that I am using the Flash file as an .exe in a given machine: Is there any chance of doing what I want? like perhaps loading a local Html with the flash and through some help with Html I can send the data to Excel?

daveystew
03-13-2008, 09:37 PM
If they already have Excel on the machine, you could create the excel layout using tabs and linebreaks, copy the output to the clipboard using System.setClipboard(), and let them handle it themselves.

If you're hosting the file as an exe, I don't think you can communicate with an HTML file.

If you host the Flash in an HTML page, you may as well use Flash to the server-side submit anyway.

Another option might be to use Adobe AIR which can host the Flash as well as communicate with the system and the server (although I don't know how much), or somehow embed the Flash file in a VB app that could communicate with Excel.

Rod F
03-14-2008, 02:17 AM
If they already have Excel on the machine, you could create the excel layout using tabs and linebreaks, copy the output to the clipboard using System.setClipboard(), and let them handle it themselves.

If you're hosting the file as an exe, I don't think you can communicate with an HTML file.

If you host the Flash in an HTML page, you may as well use Flash to the server-side submit anyway.

Another option might be to use Adobe AIR which can host the Flash as well as communicate with the system and the server (although I don't know how much), or somehow embed the Flash file in a VB app that could communicate with Excel.

Sounds interesting..
Could you elaborate a bit more, please? How do I make that Clipboard thing? You mean that the clipboard could gather the info as if it were a CSV for example and then somehow Excel would copy it to itself? How could excel pick it up from the clipboard without the user manually pasting it ... maybe a Macro but it would be better if it could be automatic. It is a very interesting suggestion

daveystew
03-14-2008, 06:12 PM
Create some tab-separated values in Flash, then copy it to the clipboard...

text = "Animal\tColor\nFrog\tGreen\nBunny\tBrown";
System.setClipboard(text)

Swap to excel and paste...

Rod F
03-14-2008, 08:08 PM
Create some tab-separated values in Flash, then copy it to the clipboard...

text = "Animal\tColor\nFrog\tGreen\nBunny\tBrown";
System.setClipboard(text)

Swap to excel and paste...
It's exactly what I ended up using...

On a side note for anybody else interested on this an directly passing the data to excel I have come with a solution with Visual Basic..

Since I am working on a local .EXE file and no need to connect back to the device or internet once I get my data on flash I managed to use fscommand( "exec" , "program.exe") to open up a VB program that runs Excel, pastes the Clipboard data, then closes itself (a few more lines and it can save the file into a folder without any more trouble and not popping any more windows..) giving the possibility of running the Flash exe for monitoring while preserving logs of data with Excel in your computer.

If there's anybody interested on this I can post it or PM me so I send it to you, but the mechanics are already explained above so if you're good with VB then you wont have any trouble in coding that little program.

daveystew
03-14-2008, 10:12 PM
Good skillz!

Rod F
03-15-2008, 12:03 AM
Good skillz!

Thanks, and thanks to all of you who gave me a hand with this problem! :D

warriorheart
04-23-2008, 11:25 AM
It's exactly what I ended up using...

On a side note for anybody else interested on this an directly passing the data to excel I have come with a solution with Visual Basic..

Since I am working on a local .EXE file and no need to connect back to the device or internet once I get my data on flash I managed to use fscommand( "exec" , "program.exe") to open up a VB program that runs Excel, pastes the Clipboard data, then closes itself (a few more lines and it can save the file into a folder without any more trouble and not popping any more windows..) giving the possibility of running the Flash exe for monitoring while preserving logs of data with Excel in your computer.

If there's anybody interested on this I can post it or PM me so I send it to you, but the mechanics are already explained above so if you're good with VB then you wont have any trouble in coding that little program.
Hi Rod,

Thanks for your brilliant idea to use VB to solve the flash data export problem. Would you mind posting up a sample of your script or sending to me?

wh

LucaSpinelli
08-13-2008, 08:54 AM
Hi Rod,

Thanks for your brilliant idea to use VB to solve the flash data export problem. Would you mind posting up a sample of your script or sending to me?

wh

Hi Rod,
Till now I used xml data connection in xcelsius connected to an .aspx file that use IIS. Now I need to find a solution using tomcat or action script to export xcelsius file to excel. Could you send to me your solution? It sounds good!!

Thank you so much.
Ps: you can find IIS solution on this blog http://biguru.wordpress.com/2008/04/26/export-data-out-of-your-xcelsius-dashboards/"

Enjoy