Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-12-2008, 08:58 PM   #1
Rod F
Registered User
 
Join Date: Mar 2008
Posts: 10
Default Exporting to Excel from DataGrid

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?
Rod F is offline   Reply With Quote
Old 03-13-2008, 01:15 PM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

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...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 03-13-2008, 07:55 PM   #3
Rod F
Registered User
 
Join Date: Mar 2008
Posts: 10
Default

Quote:
Originally Posted by CyanBlue View Post
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?
Rod F is offline   Reply With Quote
Old 03-13-2008, 08:37 PM   #4
daveystew
Dave Stewart
 
daveystew's Avatar
 
Join Date: Aug 2005
Location: London
Posts: 770
Default

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.
__________________
xJSFL | Creative | Technical
daveystew is offline   Reply With Quote
Old 03-14-2008, 01:17 AM   #5
Rod F
Registered User
 
Join Date: Mar 2008
Posts: 10
Default

Quote:
Originally Posted by daveystew View Post
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
Rod F is offline   Reply With Quote
Old 03-14-2008, 05:12 PM   #6
daveystew
Dave Stewart
 
daveystew's Avatar
 
Join Date: Aug 2005
Location: London
Posts: 770
Default

Create some tab-separated values in Flash, then copy it to the clipboard...
ActionScript Code:
text = "Animal\tColor\nFrog\tGreen\nBunny\tBrown"; System.setClipboard(text)
Swap to excel and paste...
__________________
xJSFL | Creative | Technical
daveystew is offline   Reply With Quote
Old 03-14-2008, 07:08 PM   #7
Rod F
Registered User
 
Join Date: Mar 2008
Posts: 10
Default

Quote:
Originally Posted by daveystew View Post
Create some tab-separated values in Flash, then copy it to the clipboard...
ActionScript Code:
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.
Rod F is offline   Reply With Quote
Old 03-14-2008, 09:12 PM   #8
daveystew
Dave Stewart
 
daveystew's Avatar
 
Join Date: Aug 2005
Location: London
Posts: 770
Default

Good skillz!
__________________
xJSFL | Creative | Technical
daveystew is offline   Reply With Quote
Old 03-14-2008, 11:03 PM   #9
Rod F
Registered User
 
Join Date: Mar 2008
Posts: 10
Default

Quote:
Originally Posted by daveystew View Post
Good skillz!
Thanks, and thanks to all of you who gave me a hand with this problem!
Rod F is offline   Reply With Quote
Old 04-23-2008, 10:25 AM   #10
warriorheart
Registered User
 
Join Date: Apr 2008
Posts: 1
Default

Quote:
Originally Posted by Rod F View Post
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
warriorheart is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Proper way to bind data to the DataGrid component - Best practices. andrea_muta Components 1 04-03-2007 09:13 AM
Datagrid Scrolling bug? Column repeats over and over while mouse is pressed... diesel5599 Components 2 12-18-2006 04:34 PM
flash form exporting to excel, txt, or mysql DB mikelythcott Server-Side Scripting 2 09-26-2006 10:22 PM
Please help loading data/ datagrid ericb1 Components 1 11-22-2005 07:26 PM
Export data in datagrid to Excel? sleazy_frank Components 0 01-17-2005 02:45 PM


All times are GMT. The time now is 01:46 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.