Hello to everybody,
I'm trying to order lines of an Excel's spreadsheet and set dimension of columns. i'll explain better. I've a db in MSSql server in which i've a table.
I want to put this table in Excel but ordered by a field called "filiali"...
I use DBI and DBD::ODBC to connect to MSSql server and Spreadsheet::WriteExcel::FromDB to put the table into Excel's file...
Then i use Spreadsheet::WriteExcel to order table and set coulmn width but my program tell me: "Can't call method "set_cloumn" on an undefined value at riversamento.pl line 28".
Does anybody can help me? What does it means?
How can i order by a field?
Thanks,
nathanvi
use DBI;
use strict;
use DBD::ODBC;
use Spreadsheet::WriteExcel::FromDB;
use Spreadsheet::WriteExcel;
my $user='intranet';
my $passwd='vittorio';
my $tabella='A_Filiali';
my @campi=qw/CodiceFiliale CittaFiliale Indirizzo Cap NumTel NumFax So
+cieta Apertura/;
my $file='prova.xls';
my $dbh = DBI->connect('dbi:ODBC:registri',$user, $passwd) or die "Non
+ riesco a connettermi!!\n";
my $ss = Spreadsheet::WriteExcel::FromDB->read($dbh, $tabella);
$ss->include_columns(@campi);
open FILE, ">$file" or die "Non riesco ad aprire il file!!\nErrore: $!
+\n";
binmode FILE;
print FILE $ss->as_xls;
close FILE;
my $workbook = Spreadsheet::WriteExcel->new($file);
my $worksheet=$workbook->sheets(0);
$worksheet->set_column(0,0, 30);
$workbook->close();
PS: In documentation about WriteExcel, it says "AutoFit" is impossible:
Documentation
Sorry for my bad english :-(
Steve_p - changed title to be more "searchable"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.