djbryson has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks, I need to append to an excel file. I found this code. I need more explicit instructions i guess, in particular the 1.1 section. I tried pasting this code into my script but I get errors on the 1st AddCell line. All i changed in the code to start is the xls filename. I have my variables, I just need to know how to modify this code. I want my script to append 1 row each time it runs. The row will have multiple cells. Cells are populated with posted form data, which I already have available as variables.
#1. Write an Excel file with previous data use strict; use Spreadsheet::ParseExcel::SaveParser; my $oExcel = new Spreadsheet::ParseExcel::SaveParser; my $oBook = $oExcel->Parse('temp.xls'); #1.1.Update and Insert Cells my $iFmt = $oBook->{Worksheet}[0]->{Cells}[0][0]->{FormatNo}; $oBook->AddCell(0, 0, 0, 'No(UPD)', $oBook->{Worksheet}[0]->{Cells}[0][0]->{FormatNo}); $oBook->AddCell(0, 1, 0, '304', $oBook->{Worksheet}[0]->{Cells}[0] +[0]); $oBook->AddCell(0, 1, 1, 'Kawai,Takanori', $iFmt); #1.2.add new worksheet my $iWkN = $oBook->AddWorksheet('Test'); #1.3 Save $oExcel->SaveAs($oBook, 'temp.xls'); # as the same name $oExcel->SaveAs($oBook, 'temp1.xls'); # another name

Replies are listed 'Best First'.
Re: SaveParser help
by andyford (Curate) on Dec 11, 2006 at 23:29 UTC

    I think you need to slow down and read the documentation for your module. Not that I've never done it, but blindly pasting example code is probably counterproductive.

    That said, what error are you getting?

    You should 'use warnings' as well as 'use strict'.

    non-Perl: Andy Ford