in reply to Excel File Problem

Hi joelnackman,

If you read the documentation for write_row, you'll see that it generates the same return code as write, which is:

0 for success. -1 for insufficient number of arguments. -2 for row or column out of bounds. -3 for string too long.
So I believe you are incorrectly exiting with your code:
$worksheet->write_row($excelRow, 0, \@personData) or die "Write failed +: $!\n";
That is to say, try changing or to and in the above line, and that section of your code should work.  You don't need to check the value of "$!", because it's not a system call, which may thus be giving you misleading results.

When I ran it, after "doctoring" the @personData array to hold some valid values, I was getting the error Write Failed: Bad file descriptor, which is a red herring.  When the logic was changed to interpret zero as success (and I added a line workbook->close() immediately afterwords), the Excel spreadsheet correctly contained the data I had written.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: Excel File Problem
by joelnackman (Beadle) on May 20, 2006 at 16:03 UTC
    Thanks, that seems to work much better. So I need to close the workbook after I write to it in order to save the changes? The write dosen't work even with the or fixed unless I close the workbook. Is there a way to continue editing the workbook (allow for multiple URLs to be used) after the write?
      You can read the the documentation, but I'm guessing you will need to close the workbook before the changes take effect.  So your choices are probably limited to:

      1. Closing the workbook at end of the program
      2. Closing it after writing, and (if need be) reading it back with Spreadsheet::ParseExcel.

      s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/