Home > FLEX, How-To, Perl > FLEX and Perl Export to Excel

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;

Greg FLEX, How-To, Perl

  1. August 2nd, 2008 at 01:02 | #1

    Can you tell me how to call the cgi function from flex?

    It does not look like HTTPService will work.

  2. Gopisetty Santosh Kumar
    February 27th, 2009 at 10:22 | #2

    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.

  3. March 2nd, 2009 at 18:32 | #3

    @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

  1. No trackbacks yet.