Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Set Background Color Using Spreadsheet::SaveParser

by gw1500se (Beadle)
on Dec 17, 2012 at 16:52 UTC ( #1009202=perlquestion: print w/replies, xml ) Need Help??

gw1500se has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that is working fine but I need to add one more touch. Given a certain cell content, I need to make the background color of that cell yellow. I have spent hours trying to use various things none of which work. This is what I am trying now.
my $format=$sheet->get_cell($i,$j)->get_format(); $format->set_color('yellow');
All I get is a null pointer error on the 2nd line. Can someone help? TIA.

Replies are listed 'Best First'.
Re: Set Background Color Using Spreadsheet::SaveParser
by jmcnamara (Monsignor) on Dec 17, 2012 at 17:13 UTC

    The get_format() in the first line returns a Spreadsheet::ParseExcel Format object which doesn't have a set_color() method, or set_anything() method since it is a read/information only object.

    Possibly you are getting it confused with a Spreadsheet::WriteExcel format method that you have in the same program. If that is the case, then you will have to map the Spreadsheet::ParseExcel format properties to Spreadsheet::WriteExcel format properties, one by one.


      Thanks for the reply. Not exactly confused as much as not understanding the capabilities of each. I thought SaveParser was a combined ParseExcel and WriteExcel, rather than something completely different. Logically, it seems that if I can add rows with SaveParser then I should also be able to set attributes on those rows. In any case, how do I go about updating an existing spreadsheet if not with SaveParser? Do I need to instead use both ParseExcel and WriteExcel instead? Can WriteExcel update and existing spreadsheet?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1009202]
Approved by toolic
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2020-11-25 20:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found