The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Perl Programming
|
Set Background Color Using Spreadsheet::SaveParser
Discuss Set Background Color Using Spreadsheet::SaveParser in the Perl Programming forum on Dev Shed. Set Background Color Using Spreadsheet::SaveParser Perl Programming forum discussing coding in Perl, utilizing Perl modules, and other Perl-related topics. Perl, the Practical Extraction and Reporting Language, is the choice for many for parsing textual information.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 14th, 2012, 08:02 AM
|
|
|
|
Set Background Color Using Spreadsheet::SaveParser
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. Can someone help?
Code:
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.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.
|

December 19th, 2012, 08:02 PM
|
|
Registered User
|
|
Join Date: Jul 2010
Posts: 1
Time spent in forums: 28 m 10 sec
Reputation Power: 0
|
|
|
What perl module are you using?
Have you looked at the perldoc for the module you are using?
|

December 20th, 2012, 08:16 AM
|
 |
'fie' on me, allege-dly
|
|
Join Date: Mar 2003
Location: in da kitchen ...
|
|
|
Maybe you need to pass a hex (RGB) value ?
__________________
--Ax
without exception, there is no rule ...
Handmade Irish Jewellery
Targeted Advertising Cookie Optout (TACO) extension for Firefox
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones
 
09 F9 11 02
9D 74 E3 5B
D8 41 56 C5
63 56 88 C0
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. -- Jamie Zawinski
Deta vil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
BIT COINS ANYONE
|

December 20th, 2012, 09:03 AM
|
|
|
|
Thanks for the replies. I'm using Spreadsheet::SaveParser as the subject field says. I don't think a hex RGB is the issue because it is $format that is null.
In my research I have hit a catch-22 which means I am likely missing something. I was under the impression that Spreadsheet::SaveParser was a module that combined Spreadsheet::ParseExcel and Spreadsheet:WriteExcel. However, the implication is that get_format() is not defined in SaveParser (why I don't get an error on that is another question) nor are any of the set_xxx methods. So that means I need to use ParseExcel and WriteExcel instead. The catch-22 is that I need to use SaveParser to modify an existing spreadsheet but need WriteExcel to set colors but it can only create new spreadsheets which means I have to use SaveParser, ad nauseum. This seems like a giant hole in the functionality of these modules which seems unlikely. More likely is something I am not understanding. I guess I can use a brute force method by using WriteExcel to create a new spreadsheet from the old, then delete the old and rename the new but that should be unnecessary.
|

December 20th, 2012, 10:56 AM
|
|
|
Quote: | Originally Posted by gw1500se I guess I can use a brute force method by using WriteExcel to create a new spreadsheet from the old, then delete the old and rename the new but that should be unnecessary. |
I think that is probably what you have to do.
What I am saying here may be outdated, but last time I used the Excel Perl modules, it was not possible to read from a workbook et write to the same workbook at the same time. In other woird, you could not edit an existing book.
As far as I know, the reason for it is that Microsoft is protecting its spreadsheets with CRCs or similar verification codes or keys and that the functions used for that is proprietary information. So that if you were to edit an existing Excel file and change its content, Excel would not be able to read it again.
|

December 20th, 2012, 11:14 AM
|
|
|
|
Apparently that is not completely true any more. I am indeed able to use SaveParser to edit an existing spreadsheet. As I said originally, I have it mostly working. The piece that is missing is setting cell formats.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|