Click here to get back home

Spreadsheet::ParseExcel

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Spreadsheet::ParseExcel Karan Arora 11-16-2006
Posted by Karan Arora on November 16, 2006, 6:55 am
Please log in for more thread options


Hi

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) =
$worksheet->Spreadsheet::ParseExcel::Worksheet::RowRange();
my ($columnMin,$columnMax) =
$worksheet->Spreadsheet::ParseExcel::Worksheet::ColRange();

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


Posted by Mumia W. (reading news) on November 16, 2006, 9:42 am
Please log in for more thread options


On 11/16/2006 05:55 AM, Karan Arora wrote:
> Hi
>
> 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) =
> $worksheet->Spreadsheet::ParseExcel::Worksheet::RowRange();
> my ($columnMin,$columnMax) =
> $worksheet->Spreadsheet::ParseExcel::Worksheet::ColRange();
>
> print "Row Min = ", $rowMin, " Row Max = ", $rowMax, " Column Min = ",
> $columnMin, " Column Min = ", $columnMax;
> --------------------------------------------------------------------
>

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().


--
paduille.4060.mumia.w@earthlink.net

Posted by Mick on November 17, 2006, 12:12 am
Please log in for more thread options


Hey Mumia

Thanks a lot for your help!!

Regards

Karan


Mumia W. (reading news) wrote:
> On 11/16/2006 05:55 AM, Karan Arora wrote:
> > Hi
> >
> > 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) =
> > $worksheet->Spreadsheet::ParseExcel::Worksheet::RowRange();
> > my ($columnMin,$columnMax) =
> > $worksheet->Spreadsheet::ParseExcel::Worksheet::ColRange();
> >
> > print "Row Min = ", $rowMin, " Row Max = ", $rowMax, " Column Min = ",
> > $columnMin, " Column Min = ", $columnMax;
> > --------------------------------------------------------------------
> >
>
> 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().
>
>
> --
> paduille.4060.mumia.w@earthlink.net


Posted by The Spanish Inquisition on November 18, 2006, 2:19 pm
Please log in for more thread options


Mumia W. (reading news) wrote:

> 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.

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.

Ximinez
--
Our three weapons are fear, surprise, and ruthless efficiency...
and an almost fanatical devotion to the Pope....
http://www.ai.mit.edu/people/paulfitz/spanish/t1.html
http://www.youtube.com/watch?v=gldlyTjXk9A

Similar ThreadsPosted
Spreadsheet::ParseExcel error on Perl 5.8.0 November 7, 2005, 6:02 am
FmtDefault-Warning in Spreadsheet-ParseExcel December 20, 2005, 10:50 am
Spreadsheet::ParseExcel::SaveParser changes formula text to value August 25, 2004, 9:52 am
Spreadsheet::ParseExcel : read cell-notes May 27, 2005, 11:54 am
Spreadsheet-ParseExcel: Parsing various MS Excel file versions / grabing checkbox values? September 17, 2004, 3:11 am
ParseExcel::Simple not working? September 21, 2005, 3:32 pm
Spreadsheet::WriteExcel December 7, 2005, 3:50 pm
ANN: Spreadsheet::Read 0.15 June 21, 2006, 12:40 pm
ANN: Spreadsheet::Read 0.16 July 4, 2006, 7:01 am
Re: ANN: Spreadsheet::Read 0.16 July 4, 2006, 9:36 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap