Hello Monks,
I am trying to repeat a formula with Spreadsheet::WriteExcel. I get the information from querying the database with DBI. For some reason, my formula is repeating for all the rows but the first one. Technically, it is the second row but the first row is has a name- not a number- and I don't care about formulas for that row. Anyways, here is part of my code:
use strict; use warnings; use Spreadsheet::WriteExcel; use DBI; my $file = "/path/to/file/"; my $xWB = Spreadsheet::WriteExcel->new($file); my $xWS5 = $xWB->add_worksheet('Summary'); my $format = $xWB->add_format(); $format->set_bold(); #DBI stuff here.. my $row_count = $sth->rows; my $multiply = $xWS5->store_formula("=E2*F2"); # write worksheet my $rowz = 0; my $colz = 0; $xWS5->write($rowz,$colz++, $_) for @{$sth->{NAME}}; while (my $ar = $sth->fetchrow_arrayref) { ++$rowz; $colz = 0; $xWS5->write($rowz, $colz++, $_) for @$ar; for my $line (0..$row_count) { #this arguments are row, column, formula, format, first cell, second c +ell $xWS5->repeat_formula($line, 6, $multiply, $format, "E2", 'E'.($l +ine + 1), "F2", 'F'.($line + 1)); } }
In the for loop, I am trying to repeat the formula for column G. It is doing it for all the cells in column G except G2. I tried incrementing from 1 in the for loop, taking away 1 in $line + 1, etc.. So the formula only starts repeating at G3, not G2. Any insight, as usual, is greatly appreciated. :)

In reply to Missing first row with formula by PerlSufi

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.