Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I am not able to use the functions RowRange() and ColRange() available
with the package Spreadsheet::ParseExcel::Worksheet. They return value
0 and -1 indicating that the worksheet is empty (which is definitely
not the case) and not the correct values for the range. Has anyone
faced this problem before. Please help.

use OLE;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
use Spreadsheet::WriteExcel;
use Spreadsheet::ParseExcel;

$xlfile ="c:\sample.xls";

if (-e "$xlfile")
##### OLE - Excel Connection

# Create OLE object - Excel Application Pointer
$xl_app = CreateObject OLE 'Excel.Application' || die $!;
print "Excel launched successfully  \n";
# Set Application Visibility
$xl_app-> = 0;

# Open Excel File
$workbook = $xl_app->Workbooks->Open($xlfile);
print 'Opening ', $xlfile, "....\n";
# setup active worksheet
$worksheet = $workbook->Worksheets('Test History');

#Print the SheetName
my $sheetName = $worksheet->Name;
print $sheetName," is the sheet name\n";

#Find the size of the defined cells on the sheet
my ($rowMin,$rowMax) =
my ($columnMin,$columnMax) =

print "Row Min = ", $rowMin, " Row Max = ", $rowMax, " Column Min = ",
$columnMin, " Column Min = ", $columnMax;

Re: Spreadsheet::ParseExcel

On 11/16/2006 05:55 AM, Karan Arora wrote:
Quoted text here. Click to load it

Spreadsheet::ParseExcel's RowRange() method only works on objects
created by Spreadsheet::ParseExcel->new().

Since $worksheet was created by Win32::OLE, $worksheet is the wrong kind
of object on which to invoke RowRange().

Win32::OLE and Spreadsheet::ParseExcel have nothing to do with one
another and have completely different ways if interacting with an Excel
file. If you use one in a script, it's unlikely you'll need the other.

I advise you to find the Win32::OLE (Excel ?) equivalent of RowRange().


Re: Spreadsheet::ParseExcel

Hey Mumia

Thanks a lot for your help!!



Mumia W. (reading news) wrote:
Quoted text here. Click to load it

Re: Spreadsheet::ParseExcel

Mumia W. (reading news) wrote:

Quoted text here. Click to load it

It might be a good idea to use the two if you want your script to be as
portable as possible. An application of mine uses Win32::OLE if running
in Windows and Excel's available an Spreadsheet::ParseExcel if it isn't.

S::P seems to work well enough inpractice, so I guess I could've used
just that.

Our three weapons are fear, surprise, and ruthless efficiency...
and an almost fanatical devotion to the Pope....


Site Timeline