Subject: | SaveParser omits merged area format |
Date: | Fri, 12 Nov 2010 14:00:42 +0000 |
To: | bug-Spreadsheet-ParseExcel [...] rt.cpan.org |
From: | Paul Thornton <prt [...] prt.org> |
I've been trying to track down an issue whereby
Spreadsheet::ParseExcel::SaveParser still does not correctly save merged
areas. I know this has been discussed in the past, and I've tested with
the latest version, but I'm still having problems. I'm not familiar
enough with Excel formatting or the inner workings of ParseExcel to
offer a patch unfortunately.
My template "test-in.xls" was created with Excel 2003 SP3 (version
11.8328.8329). It contains an area which has been merged and set to
wrap text, and is then saved. It makes no difference if there is
actually some text in the area or not.
When the test program "testmerged.pl" is run, a string is written to the
cell OK, but in the output file it creates the merge is removed. The
wrap text format is retained OK. The output spreadsheet is "test-out.xls"
The dump of $cell when running the test shows that the cell has Merged=1
set, so the issue looks to be in SaveParser. If I re-run my test
program using the "test-out" as an input, the Merged=1 option is missing
from the same dump.
Output from the versions program gives:
Perl version : 5.008009
OS name : freebsd
Module versions: (not all are required)
Spreadsheet::ParseExcel 0.58
Scalar::Util 1.22
Unicode::Map 0.112
Spreadsheet::WriteExcel 2.37
Parse::RecDescent 1.963
File::Temp 0.22
OLE::Storage_Lite 0.19
IO::Stringy 2.110
Regards,
Paul.
#!/usr/bin/perl
# Test ParseExcel
use Spreadsheet::ParseExcel::SaveParser;
use Data::Dumper;
$templatefile = "./test-out.xls";
$tmpfile = "./test-out2.xls";
$parser = Spreadsheet::ParseExcel::SaveParser->new();
$template = $parser->Parse($templatefile);
$worksheet = $template->worksheet(0);
# Write some text into B4 - this is the first cell
# of a 4x2 merged area. This cell already exists
# in the template as a merged area, we're just
# adding the text to it.
$cell = $worksheet->get_cell(3,1);
$format_id = $cell->{FormatNo};
$worksheet->AddCell(3,1,'This is some text that should wrap and merge into a block from B4-E5', $format_id);
print Dumper($cell);
# Write some text into a normal cell
$worksheet->AddCell(7,1,'After spreadsheet');
$template->SaveAs($tmpfile);
print 'Saved file as: ' . $tmpfile . "\n";
exit(0);
Message body not shown because it is not plain text.
Message body not shown because it is not plain text.