views:

3265

answers:

4

How do I export data in my datagrid to an Excel file in Flex?

Can anyone provide some examples for that? I am browsing but couldn't find out a single example of that kind.

EDIT

Browsed a lot and found out how to convert datagrid data to csv format. Now How to convert that to excel? Is there a way to do that without using any server script ? Can't it be done in Flex alone?

+1  A: 

Excel reads the HTML table as a kind of spreadsheet. Just read the grid row by row, column by column and produce a set of HTML table cells and produce a file named whatever.xls.

Rafal Ziolkowski
I have created it in the form of html tables. How to produce an excel file?
Angeline Aarthi
+1  A: 

If you have a Java servlet back-end you can use a servlet to output the file.

My only Flex-only idea was to output the CSV data to a popup with a textarea that could be copied and pasted into a file by the user.

susichan
+2  A: 

There is as3xls for you to write xls file. It only support a single sheet(but I think that's fine).

But I think using csv or html as stated by @susichan and @Rafal Ziolkowski will be more simple if you do not need to use excel functions (like cell formula).

Oh, and there is csvlib for writing csv. For html, do it like writing XML will be fine.

Andy Li
A: 

here is your answer

http://learnflexair.wordpress.com/category/uncategorized/air/

Mahesh