Re: Spread***::Parse & Write Excel



In article <1a5d.47274e25.82120@zem>, Justin C
<justin.0711@xxxxxxxxxxxxxx> wrote:

I get the following error when running my script:

Can't locate object method "get_xf_index" via package
"Spread***::ParseExcel::Format" at
/usr/local/share/perl/5.8.8/Spread***/WriteExcel/Work***.pm line
1453


Here is some code:

#!/usr/bin/perl

use warnings;
use strict;
use Spread***::ParseExcel;
use Spread***::WriteExcel;

my $inFile = "some.xls";
my $outFile = "output.xls";
my $lastCol = 9; # We don't want the data beyond this point
my $firstRow = 4;# counting from 0, 0-3 are the front page for printing
my $lastRow;

my $inBook = Spread***::ParseExcel::Workbook->Parse($inFile);
my $outBook = Spread***::WriteExcel->new($outFile);
my $out*** = $outBook->add_work***();

foreach my $in***(@{$inBook->{Work***}}) { # there's only one
$lastRow = $in***->{MaxRow};

foreach my $row ( $firstRow .. $lastRow) {
foreach my $col ( 0 .. $lastCol) {
# get contents of cell
my $cellcontent = $in***->{Cells}[$row][$col]->{_Value};
my $cellFormat = $in***->{Cells}[$row][$col]->{Format};
# write contents of cell to new work***
$out***->write_string($row-3, $col-5, $cell, $cellFormat);

I think you mean $cellcontent here instead of $cell. Please
cut-and-past the exact code showing your problem.

}
}
}

*** END ***

$cellFormat contains a hash reference, AFAICT. I was hoping that that
would be accepted by the ...::WriteExcel and generate what I want.

Can anyone spot anything obviously wrong with the above that may help
me? Are there any Spread***::[Parse|Write]Excel experts here who have
suggestions?

Spread***::ParseExcel and Spread***::WriteExcel are separate
modules that have no relationship to each other and were written by
different authors. In particular, they each have their own concepts of
a "Format" object or class, and these are not shared. You cannot fetch
the format of a cell in an existing spread*** and transfer it whole
to a new spread***. You are going to have to play around with
extracting the various pieces of the existing cell format and transfer
each piece to the new spread*** using the syntax of
Spread***::WriteExcel.

Your error message occurs because you have sent a blessed object of the
Spread***::ParseExcel::Format to the write_string method of a
Spread***::WriteExcel::Work*** object, and it is trying to call the
get_xf_index method, which does not exist in the
Spread***::ParseExcel::Format class.

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
.