J
Justin C
I've been trying to follow the examples given in the
Spreadsheet:
arseExcel module and appear to have become stuck. I have a
spreadsheet, most of which I need to copy to a new spreadsheet...
A6 to J6084 (well, that last number changes each time the sheet is
updated but I can extract that info from the sheet).
What I have so far is:
---- START ----
use strict ;
use warnings ;
use Spreadsheet:
arseExcel ;
use Spreadsheet::WriteExcel ;
my $orig_file = "/home/data/common/alan/excel/CATALOGU/A_TO_Z.XLS" ;
my $new_file = "/var/www/download/files/complete_listing.xls" ;
my $newbook = Spreadsheet::WriteExcel->new($new_file) ;
my $newsheet = $newbook->add_worksheet() ;
my $oldbook = new Spreadsheet:
arseExcel::Workbook->Parse($orig_file) ;
my $oldsheet = $oldbook->Worksheet('Sheet1') ;
my $lastrow = $oldsheet->{MaxRow} ;
print $lastrow, "\n" ;
my $srow = 6 ; #start row - after all the header/front page stuff.
my $lcoumn = 9 ;#last col. - leave off the supplier detail.
my $r = $srow ;
while ( $r <= $lastrow ) {
my $c = 0 ;
while ( $c < 10 ) {
my $nsr = $r - $srow ; # new sheet row number
my $cell = $oldsheet->{Cells}[$r][$c] ;
$newsheet->write($nsr , $c , $cell->Value) if ( $cell->Value ) ;
$newsheet->write($nsr , $c , $cell->Format) if ( $cell->Format ) ;
printf "Row: %d Col: %d Nsr: %d\n", $r, $c, $nsr ;
$c++ ;
}
$r++ ;
}
---- END ----
The new xls file gets created, but it's empty. The while loops iterate
over the rows and columns in the original OK - well, according to the
second print statement above it's all incrementing properly.
If anyone can tell me why either the cell value and formatting aren't
being read, or they aren't being written, I'll be very grateful.
Justin.
Spreadsheet:
spreadsheet, most of which I need to copy to a new spreadsheet...
A6 to J6084 (well, that last number changes each time the sheet is
updated but I can extract that info from the sheet).
What I have so far is:
---- START ----
use strict ;
use warnings ;
use Spreadsheet:
use Spreadsheet::WriteExcel ;
my $orig_file = "/home/data/common/alan/excel/CATALOGU/A_TO_Z.XLS" ;
my $new_file = "/var/www/download/files/complete_listing.xls" ;
my $newbook = Spreadsheet::WriteExcel->new($new_file) ;
my $newsheet = $newbook->add_worksheet() ;
my $oldbook = new Spreadsheet:
my $oldsheet = $oldbook->Worksheet('Sheet1') ;
my $lastrow = $oldsheet->{MaxRow} ;
print $lastrow, "\n" ;
my $srow = 6 ; #start row - after all the header/front page stuff.
my $lcoumn = 9 ;#last col. - leave off the supplier detail.
my $r = $srow ;
while ( $r <= $lastrow ) {
my $c = 0 ;
while ( $c < 10 ) {
my $nsr = $r - $srow ; # new sheet row number
my $cell = $oldsheet->{Cells}[$r][$c] ;
$newsheet->write($nsr , $c , $cell->Value) if ( $cell->Value ) ;
$newsheet->write($nsr , $c , $cell->Format) if ( $cell->Format ) ;
printf "Row: %d Col: %d Nsr: %d\n", $r, $c, $nsr ;
$c++ ;
}
$r++ ;
}
---- END ----
The new xls file gets created, but it's empty. The while loops iterate
over the rows and columns in the original OK - well, according to the
second print statement above it's all incrementing properly.
If anyone can tell me why either the cell value and formatting aren't
being read, or they aren't being written, I'll be very grateful.
Justin.