Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spreadsheet::ParseExcel help needed ....

Status
Not open for further replies.

rab54

Programmer
Jan 28, 2004
112
GB
OK gurus - I need to read in a previously generated spreadsheet - and then add new data from a db -

I have this so far -

for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++) {

$oWkS = $oBook->{Worksheet}[$iSheet];

for(my $iR = $oWkS->{MinRow} ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++){

$iR = $oWkS->{MaxRow};

$iR++;

my $date = "28/08/2004";
my $name = "Joe Bloggs";
my $contact = "0845 055 0505";

#1.1.Update and Insert Cells
my $iFmt = $oBook->{Worksheet}[$iSheet]->{Cells}[0][0]->{FormatNo};
$oBook->AddCell(0, $iR , 0, $date, $oBook->{Worksheet}[0]->{Cells}[0][0]->{FormatNo});
$oBook->AddCell(0, $iR, 0, $name, $oBook->{Worksheet}[0]->{Cells}[0][0]);
$oBook->AddCell(0, $iR, 1, $contact,$oBook->{Worksheet}[0]->{Cells}[0][0]);
# $oBook->AddCell(0, $iR, 1, $contact , $iFmt);

}
}

This work ok - it puts in the variables in the correct cells but only on the first workbook -

There are 12 - what am I missing ?

cheers in advance

Rab
 
SheetCount, you sure about this, hard-code in 11, and see what happens

--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
Hi

An ilustrative example how to use sheetcounts

sub analyzing_excel_file {

my $oExcel = new Spreadsheet::parseExcel;
my $oBook = $oExcel->Parse($filename_datafill);
print "FILE NAME:", $oBook->{File} , "\n";
print "NUMBER OF SHEETS :", $oBook->{SheetCount} , "\n";
print "AUTHOR OF THE FILE:", $oBook->{Author} , "\n" if defined $oBook->{Author};

for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++) {
$oWkS = $oBook->{Worksheet}[$iSheet];
print "SHEET NAME:$oWkS->{Name}=> $iSheet\n";
$iSheet_start= $iSheet if ( $oWkS->{Name} =~m"Start");
$iSheet_datafill_user_guide= $iSheet if ( $oWkS->{Name} =~m"Datafill");
$iSheet_datasites= $iSheet if ( $oWkS->{Name} =~m"BCF");
$iSheet_adce= $iSheet if ($oWkS->{Name} =~m"ADCE");
$iSheet_mal_bal= $iSheet if ( $oWkS->{Name} =~m"MAL");
$iSheet_dap= $iSheet if ( $oWkS->{Name} =~m"DAP");
$iSheet_lcse= $iSheet if ( $oWkS->{Name} =~m"LCSE");
}

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top