in reply to ParseExcel::SaveParser, colors & google docs


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.

Replies are listed 'Best First'.
Re^2: ParseExcel::SaveParser, colors & google docs
by irDanR (Novice) on Aug 06, 2010 at 16:25 UTC

    Your code works exactly as expected! Oops, I probably would have found that documentation had I thought to try my search with colour instead of color. Thanks for the help!