FLEX and Perl Export to Excel
Need to export a Flex Datagrid to Excel CSV?
Here is a link to the Flex code
The flex code will convert the DataGrid to a CSV string. Which you will then post to a cgi….code below.
You can see it in action on my Dividend Reinvestment ToolÂ
#!/usr/bin/perl
use CGI qw(:standard);
my $cgi = new CGI;
my $count = 0;
use CGI::Carp qw(fatalsToBrowser);
$title=$cgi->param('title');
$html=$cgi->param('htmltable');
$type = $cgi->param('type');
if ($type = "CSV") {
print $cgi->header(-expires=>'now', -type=>'application/x-csv', -content_disposition=>"attachment; filename=$title.csv");
print "$html";
}
else {
print $cgi->header(-expires=>'now', -type=>'application/octet_stream', -content_disposition=>"attachment; filename=$title.xls");
print $cgi->start_html(-title => 'Export'
);
print "$html";
print $cgi->end_html;



Can you tell me how to call the cgi function from flex?
It does not look like HTTPService will work.
It is giving the Datagrid Data in CSV format and printing it in a TextArea , instead how can we create an Excel file and save Datagrid Data in it. can you please help me in this regard.
@Gopisetty Santosh Kumar
I think the best approach would be to write a parser in actionscript that would convert a datagrid to html as Excel can understand HTML. Then do the same thing I am explaining above, but output .xls