Hello monks, I have a script that queries the database and writes the information the an excel file. The issue is that I want to take a date at the command line when the script is run and write it to an entire excel column. When I run it, it gives me '211' just on the first cell in the column (D) that I want, and not the full date(ie. 20130729) through the whole column. I am running it like  perl script.pl 20130729
Here is most of my script:
use strict; use warnings; use diagnostics; use DBI; use DateTime; use Date::Format; use MIME::Entity; use Spreadsheet::ParseExcel; use Spreadsheet::WriteExcel; my $user_date = $ARGV[0]; my $database = "workflow"; my $host = "database.local"; my $user = "$user"; my $pw = "$pw"; my $dbh = DBI->connect("dbi:mysql:$database:$host", $user, $pw,) or di +e "Database connection FAILED: $DBI::errstr"; my $sth = $dbh->prepare( "SELECT * stuff"); $sth->execute(); my $xWB = Spreadsheet::WriteExcel->new('/path/to/file.xls'); my $xWS = $xWB->add_worksheet('sheet'); $xWS->write(0,0, 'Account'); $xWS->write(0,1, 'PDF Name'); $xWS->write(0,2,'Bill Number'); $xWS->write(0,3, 'Mailed Date'); $xWS->set_column('A:A', 18); $xWS->set_column('B:B', 25); $xWS->set_column('C:C', 12); $xWS->set_column('D:D', 12); while (my $ar = $sth->fetchrow_arrayref) { s{^.*/}{} for @$ar; ++$row, $col = 0; $xWS->write($row,$col++,$_) for @$ar; } #I want the total number of rows and write the user input date through + all rows in this column #$xWS->write("D2:D$row", $user_date); # 212 is the actual number of rows known by viewing the file $xWS->write('D2:D212', $user_date); $xWB->close(); $sth->finish(); $dbh->disconnect;
I also want to automatically get the total number of rows and write the user input date to all of column D, but I can get to that later. For now I need help understanding why the date is not writing. Any help is very appreciated !

In reply to User input into Excel 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.