Spreadsheet::ParseExcel : read cell-notes
am 27.05.2005 10:54:03 von pilsl
Is there any way to read the notes/comments attached to a cell using
SpreadSheet::ParseExcel or a different module? I searched CPAN and
google and didnt find any hints.
thnx,
peter
--
http://www.goldfisch.at/know_list
Re: Spreadsheet::ParseExcel : read cell-notes
am 28.05.2005 23:35:55 von Jack D
"peter pilsl" wrote in message
news:4296e04a$0$583$79720d31@newsreader.inode.at...
>
> Is there any way to read the notes/comments attached to a cell using
> SpreadSheet::ParseExcel or a different module? I searched CPAN and
> google and didnt find any hints.
>
You can use Win32::OLE to do this:
######################################
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
use strict;
my $xl = Win32::OLE->GetActiveObject('Excel.Application') ||
Win32::OLE->new('Excel.Application');
die "Cannot start Excel" unless $xl;
my $workbook=$xl-> Workbooks->Open('C:\\temp\\book1.xls');
my $worksheet=$workbook->Worksheets('Sheet1');
my $LastRow = $worksheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,
SearchOrder=>xlByRows})->{Row};
my $LastCol = $worksheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,
SearchOrder=>xlByColumns})->{Column};
print "Number of used rows: $LastRow\n";
print "Number of used cols: $LastCol\n";
my $lnRow=1;
my $lnCol=1;
while ($lnRow <= $LastRow) {
$lnCol = 1 if ($lnCol > $LastCol);
my $notes = $worksheet->Cells($lnRow,$lnCol)->{NoteText};
print $notes,"\n" if ($notes);
$lnRow++ if $lnCol == 1;
$lnCol++;
}
$xl->Quit;
__END__
###############################
hth -
Jack