# Open an existing file with SaveParser my $parser = Spreadsheet::ParseExcel::SaveParser->new(); my $template = $parser->Parse('perl.xls'); my @s; $s[$_] = $template->worksheet( "cpzea0".$_."a0001" ) for 1..8; ###################################################################### +##################################################################### +################ #####This will retrieve the last row where value was written form the +first worksheet so that we can continue writing from the same place## +################ my $cell = $s[1]->get_cell(1000,1); $lrow= $cell->value; print $lrow; ###################################################################### +##################################################################### +############### my $workbook= $template->SaveAs('newfile.xls'); for ($i=0;$i<=7;$i++) { $s[$i+1] = $workbook->sheets($i) ; } ###################################################################### +##################################################################### +################ ####All the Formats will be described within this space############### +##################################################################### +################# my $text_format = $workbook->add_format( bold => 1, size => 10, font =>'arial', bg_color =>'green', align =>'center', border =>'1' ); my $text_format1 = $workbook->add_format( size => 10.5, font =>'consolas', align =>'center', ); my $text_format2 = $workbook->add_format( size => 10.5, font =>'consolas', align =>'center', bg_color =>'dark blue' +, border =>'1' ); my $text_format3=$workbook->add_format( size => 10.5, font =>'consolas', align =>'center', border =>'1' , color =>'red', bold =>'1', ); ###################################################################### +##################################################################### +################# $row=$lrow + 3; $col=1; $start=$row; for($i=1;$i<=8;$i++) { $f=0; for ($c=$col+1;$c<=8;$c++) { $s[$i]->write($start,$c,$header[$f++],$text_format); } } my $col = 1; for ($i=1;$i<=8;$i++) { for ($r=0;$r<=24;$r++) { $row++; for ($c=0;$c<=4;$c++) { $col++; $s[$i]->write($row,$col,$arrays[$i][$r][$c],$text_form +at1); } $col=1; } $row=$lrow + 3; } #This part will create Formulae for current day my $c=7 ; for ($i=1;$i<=8;$i++) { for ($r=$lrow + 4;$r<=$lrow + 28;$r++) { $c=$r + 1; $s[$i]->write($r,7,"=F$c/G$c",$text_format2); $s[$i]->write($r,8,"=F$c/SUM(C$c:D$c)",$text_format2); } } ###################################################################### +##################################################################### +############## #This part is for writting the last line of the data which calculates +the sum of each parameter for a given day############################ +############### my $g =2; $row=$lrow + 28; $val=$lrow + 5; for ($i=1;$i<=8;$i++) { $s[$i]->write($row,$g++,"Total",$text_format3); $s[$i]>write($row,$g++,"=SUM(D$val:D$row)",$text_format3); $s[$i]->write($row,$g++,"=SUM(E$val:E$row)",$text_format3); $s[$i]->write($row,$g++,"=SUM(F$val:F$row)",$text_format3); $s[$i]->write($row,$g++,"=SUM(G$val:G$row)",$text_format3); $g=2; } ###################################################################### +##################################################################### +################ $s[1]->write(1000,1,$lrow + 30); $workbook->close();

In reply to Values of Formulas also not preserved with save parser ? by devbond

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.