Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Preserving merged cells when using Spreadsheet::WriteExcel and ParseExcel

by metaperl (Curate)
on Sep 30, 2011 at 15:18 UTC ( #928832=perlquestion: print w/replies, xml ) Need Help??
metaperl has asked for the wisdom of the Perl Monks concerning the following question:

I'm attempting to modify an Excel spreadhsheet which spreadsheet has a merged cell at D8.

I wrote a small program which reads the format of D8 and writes some data back to D8 in a new sheet with that formatting:

#!/usr/bin/perl -w use strict; use Smart::Comments; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; # Open the template with SaveParser my $parser = new Spreadsheet::ParseExcel::SaveParser; my $template = $parser->Parse('sat.xls'); warn "template:$template:"; my $sheet = 0; my $workbook; { # SaveAs generates a lot of harmless warnings about unset # Worksheet properties. You can ignore them if you wish. local $^W = 0; # Rewrite the file or save as a new file $workbook = $template->SaveAs('new.xls'); } # Use Spreadsheet::WriteExcel methods my $worksheet = $workbook->sheets(0); my $row = 7; my $col = 3; # Get the format from the cell my $format = $template->{Worksheet}[$sheet]->{Cells}[$row][$col]->{For +matNo}; $worksheet->write( $row, $col => 'some_originating_entity', $format );

However, the new sheet has all the merged cells unmerged.

Is there a way to preserve merged cells when updating/modifying cells in the template spreadsheet?

Both the program and the initial spreadsheet are here
  • Comment on Preserving merged cells when using Spreadsheet::WriteExcel and ParseExcel
  • Download Code

Replies are listed 'Best First'.
Re: Preserving merged cells when using Spreadsheet::WriteExcel and ParseExcel
by metaperl (Curate) on Sep 30, 2011 at 18:09 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://928832]
Approved by keszler
help
Chatterbox?
[Tanktalus]: perldigious: I'm not looking to get rich. I'm looking for interesting work, with good continuity of employment, and maintenance of our current lifestyle. (An improvement wouldn't be bad, either, but that's not a requirement ;) )
erix enjoys the confusion++
[Your Mother]: :P
[Tanktalus]: Without confusion, I'd be out of a job ;)
[Tanktalus]: Already. :D
[Lady_Aleena]: Your Mother, I wish it did have a way to put in a directory to search.
[Your Mother]: Thatís silly. Itís a string op tool.
[Lady_Aleena]: So I guess I'll go argue with File::Find and grep.
[Your Mother]: I would probably use Path::Tiny instead for it's slurp and such.
[Your Mother]: s/it's/its/

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-05-23 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?