Subject: | Excel complains of file corruption if worksheet name is specified (using perl 5.6.1) |
The perl script below produces a file that Excel can recover the data from, but not the formatting. This is using perl 5.6.1 on i686-linux, and we've been using Spreadsheet::WriteExcel (v2.13) and Spreadsheet::WriteExcel::Big (v2.01) with some success to generate multi-worksheet workbooks, so I'm somewhat mystified as to how this could happen. I suspect this is the same bug discussed at http://www.perlmonks.org/index.pl?node_id=384154, which the original poster never got around to filing a bug on.
Setting the worksheet name to an empty value results in a workbook that Excel is happy with.
Other behaviors noticed:
* putting in a lot of data rows seems to break the sheet name even worse(it becomes "UnknownSheet1", rather than reverting to the default "Sheet1").
* trying with two worksheets produces the same behavior, neither better nor worse (demonstrated optionally with the obviously-named template parameter).
* trying with two worksheets, when the first has more than three rows of data, causes the second worksheet to simply disappear (ditto).
* using the Spreadsheet::WriteExcel::Big renderer appears to simply produce no output at all, but that seems to be a separate bug
#!/usr/local/bin/perl
use Excel::Template;
use strict;
my $t = Excel::Template->new(filename=>\*DATA) or die $@;
$t->param("TOPCELL"=>"Generated for testing with no timestamp") or die $@;
$t->param(INCLUDE_SECOND_SHEET=>0);
$t->param(BREAK_SECOND_SHEET=>0);
print $t->output or die $@;
__END__
<workbook>
<worksheet name="foo">
<row><bold><cell><var name="TOPCELL" /></cell></bold></row>
<row><format align="center" valign="top" bold="1">
<cell>Have some</cell>
<cell>Text</cell><cell>More</cell><cell text="Text" />
</format>
</row>
<if name="BREAK_SECOND_SHEET">
<row><format align="center" valign="top" bold="1">
<cell>Have some</cell>
<cell>Text</cell><cell>More</cell><cell text="Text" />
</format>
</row>
</if>
</worksheet>
<if name="INCLUDE_SECOND_SHEET">
<worksheet name="bar">
<row><bold><cell>This is sheet two</cell></bold></row>
<row><format align="center" valign="top" bold="1">
<cell>Have some</cell>
<cell>Text</cell><cell>More</cell><cell text="Text" />
</format>
</row>
</worksheet>
</if>
</workbook>