Ok, I've RTFM several times, and still I'm not quite grasping how to get the background color (shading) of a cell in an Excel worksheet with Spreadsheet::ParseExcel.
I can get the data from the individual cells, taking nearly directly from the well-cited example included in the documentation:
$oBook = Spreadsheet::ParseExcel::Workbook->Parse("$strExcelPath");
foreach my $oWkS (@{$oBook->{Worksheet}}) {
print "--------- SHEET:", $oWkS->{Name}, "\n";
for(my $iR = $oWkS->{MinRow} ;
defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ;
$iR++) {
for(my $iC = $oWkS->{MinCol} ;
defined $oWkS->{MaxCol} && $iC <= $oWkS->{
+MaxCol} ; $iC++) {
$oWkC = $oWkS->{Cells}[$iR][$iC];
print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC)
+;
But I need not only the cell value, defined in $oWkC->Value, but the background color of the cell.
The documentation provides that "Format" is a cell property, the same way "Value" is. So...
$oFormat = $oWkC->Format;
Should return the format information to the $oFormat object.
Now, Fill is a property of the Format object, so...
$oFill = $oFormat->Fill;
Should return, according to the documentation:
Array ref of fill pattern and color indexes : [Pattern, Front Color, Back Color]
But this is where I'm stuck. No matter how many different ways I've tried writing it, I am unable to get the program to spit out the Pattern, front color, or back color.
Can anyone help me out with the proper format of this?
Update - Thank you very much, ptum and jmcnamara - your replies not only helped me reach my solution, but have helped me learn a little bit more about this sort of form (and how the documentation may appear behind it!). As usual, you more experienced monks are knowledgeable and helpful!