Pages

Showing posts with label Codes. Show all posts
Showing posts with label Codes. Show all posts

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/

 

site weekly hits