Pages

Monday, October 17, 2011

Extract Excel contents from perl

This code is used to calculate no. of w/s in excel file and read the worksheets' name.

my $sheetcnt = $Book->Worksheets->Count();
foreach (1..$sheetcnt){
print "\t" .$Book->Worksheets($_)->{Name} ."\n";
}


While last row and column can be read by using this:-

Finding the last Column and Row

my $LastRow = $Sheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,
SearchOrder=>xlByRows})->{Row};

my $LastCol = $Sheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,
SearchOrder=>xlByColumns})->{Column};

All of above code are use Win32::OLE without using complicated spreadsheet perl module.

Reference
1. http://www.perlmonks.org/?node_id=153486
2. http://www.ngbdigital.com/perl_ole_excel.html
3. http://perlguru.com/

Tuesday, October 4, 2011

王力宏 Wang Leehom 依然愛你 Still In Love With You

 

site weekly hits