Hello Monks,
Have a great day. I am trying to append an excel sheet with the following data servername,username and password.
But I am not able to append the excel file using Spreadsheet::writeExcel module. I tried in the google and it says that "Spreadsheet::parseExcel::Saveparser can be
used. But I do not find it will help to append the existing excel file. Could you please help me how to append data in the excel file?
I know that using Spreadsheet::parseExcel we can read all the rows and files, then we can write it to new excel file. But in my excel file it is having multiple sheets.
I like to append only one excel sheet with only one row. so i am looking for appending the row in the sheet.
Here is the code,
use strict;
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel;
use Spreadsheet::ParseExcel::Utility qw(ExcelLocaltime);
use DateTime::Format::Excel;
my @Array = ();
my $server = "localhost";
my $user = "lion";
my $pass = "tiger";
push(@Array, $server);
push(@Array, $user);
push(@Array, $pass);
my $inputfile = "C:\\perl\\bin\\input.xls";
$workbook = Spreadsheet::WriteExcel->new("$inputfile");
$sheet = $workbook->add_worksheet("serverdata");
print"File=> $inputfile worksheet=> $sheet\n";
# Add a Format
$format = $workbook->add_format();
$bgformat = $workbook->add_format();
for(my $i =0; $i <= 2; $i++){
$sheet1->write(0, $i, $writeArray[$i], $bgformat);
}
Existing File content(input.xls):
server user pass
red lang pian
green weer xisass
Expected output File content(input.xls):
server user pass
red lang pian
green weer xisass
loalhost lion tiger
Could any one help me to add this entry in the excel sheet.
THANKS.
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.