in reply to Spreadsheet Parsing problem

It seems this is something worse than we all expected. I tried to modify the code slightly and replaced the last line with

open OUT, '>', 'c:\temp\xls\Out.xls' or die "Can't create the file: $! +\n"; binmode OUT; print OUT $ss->data; close OUT;
but still the resulting XLS doesn't show right.

If I print the @idata in hexa there IS only LF, and if I look with a hexa editor on both the original XLS and the created one BOTH contain just LF between the lines yet ... one works and the other does not.

This starts to look like a bug in Spreadsheet::WriteExcel::Simple or Spreadsheet::WriteExcel to me :-(

Jenda
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
   -- Rick Osborne

Edit by castaway: Closed small tag in signature

Replies are listed 'Best First'.
Re: Re: Spreadsheet Parsing problem
by jmcnamara (Monsignor) on Apr 29, 2003 at 22:41 UTC

    This starts to look like a bug in Spreadsheet::WriteExcel::Simple or Spreadsheet::WriteExcel to me

    The following example might clarify what is happening:

    #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new("reload.xls"); my $worksheet = $workbook->addworksheet(); my $format = $workbook->addformat(text_wrap=> 1); my $str = "A\nB\nC"; $worksheet->write('B2', $str ); $worksheet->write('B4', $str, $format);

    This produces an Excel file that looks a little like this except the square described by artist is shown as an underline:

    ------------------------------------------ | | A | B | C | D | ... ------------------------------------------ | 1 | | | | | ... | 2 | | A_B_C | | | ... | 3 | | | | | ... | | | A | | | ... | | | B | | | ... | 4 | | C | | | ... | 5 | | | | | ... | 6 | | | | | ... |...| ... | ... | ... | ... | ...

    The difference is caused by the presence of the format (which is missing from artist's code). This can also be verified within Excel by toggling the Format->Cells->Alignment->Wrap Text option.

    As such, I don't think that this is a bug. :-)

    And just to clarify a point raised in some of the other nodes. The character required to generate a wrap is \n (0x0A) and not \r (0x0D). Here is a hexdump of the wrapped ABC string taken from a real Excel file:

    41 0a 42 0a 43
    --
    John.