Excel uses a palette of 64 colours. These colours are referred to internally using an index number.

In general a standard palette is used but it can be redefined by the user. As such, colour index 42 may be red in one workbook and green in another.

SaveParser doesn't try to map the colour palette between the original and target workbooks (which is a bug) so this may be causing the effect that you are experiencing.

You can try work around the issue as follows:

#!/usr/bin/perl use strict; use warnings; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; my $parser = Spreadsheet::ParseExcel::SaveParser->new(); my $template = $parser->Parse('color01.xls'); # Get the underlying Spreadsheet::WriteExcel workbook. my $swe_workbook = $template->SaveAs('color02.xls'); # Map the original color palette to the new workboook. for my $i ( 8 .. 63 ) { $swe_workbook->set_custom_color( $i, '#' . $parser->ColorIdxTo +RGB($i) ); }

See the Spreadsheet::WriteExcel docs for more information on Colours in Excel.

Update: I've logged this issue on rt.cpan.org.

--
John.


In reply to Re: ParseExcel::SaveParser, colors & google docs by jmcnamara
in thread ParseExcel::SaveParser, colors & google docs by irDanR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.