Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

want to export mysql values into excel using perl...

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
i have a list of information that is generated from mysql and displayed on to the screen. i want to take that info, either from mysql or on-screen and export (or import) that info to excel. how should i do this, or which direction should i head in?

- g
 
using an ODBC query into Excel is what I'd probably do here.

Data->Import External Data->New Database Query

For a truly perlish way, you could have a script create your spreadsheet, and populate it from Perl, but how many times is this required, and does the effort warrant it is what I'd be thinking

--Paul

There's a number of Excel modules on CPAN, if they're not also available as PPD's from ActiveState


cigless ...
 

okay, but what i'm looking for is something on-screen to export into excel...this is for an admin to do directly from the website.

a button that says 'click to export to excel'...

any ideas?

- g
 
Have a look to Spreadsheet::Write Excel Module


You could get the outpout from the database and generate an excel file by yourself.

Or you can create a csv file and convert it to excel:

#!/opt/nokianms/bin/perl
# From csv to excel

#use strict;
use Spreadsheet::WriteExcel;

open (CSVFILE, "myfile.csv") or die "myfile.csv: $!";
my $excel = Spreadsheet::WriteExcel->new("mysheet.xls");
my $worksheet = $excel->add_worksheet();
my $row = 0;
my $col;

while (<CSVFILE>) {
chomp;
my @Fld = split('\,', $_);
$col = 0;
foreach my $token (@Fld) {
$worksheet->write($row, $col, $token);
$col++;
}
$row++;
}

Cheers!

dmazzini
GSM System and Telecomm Consultant
 
Excel can read *.csv files already. There doesn't seem to be much point in convering them to Excel, unless you need to add formatting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top