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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.