You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using my code getcellcolor(), I get undef or garbage back that is meaningless. Here is my subroutine below.
###########################################################################
# In: Workbook object;
# Sheet object;
# row number (0-based);
# col number (0-based);
# XLSX filename (string);
# tab name (string);
# row in spreadsheet (just $row+1), 1-based.
# Out: String of cell contents.
# How the parameters passed in are created:
# my $wkbkin=$parser->parse($xlsfnin);
# if (not $sheetin=$wkbkin->worksheet(0)) # Get first tab.
# {
# $s=$prefixsp."$procname ERROR: Could not get first tab in $xlsfnin";
# print "$s\n";
# $err=$s;
# exit 1;
# }
sub getcellcolor
{my($wkbkin,$sheetin,$row,$col,$xlsfnin,$tab,$zpos)=@_;
my($s,$t);
my $procname=(caller(0))[3];
my $prefixsp=' ';
my $new='';
my $cellin;
my $v='';
eval {
$cellin=$sheetin->get_cell($row,$col);
};
if ($@)
{
$s="$procname ERROR cell ".makecellname($row,$col).
" from XLSX sheetin->get_cell. ";
if ( defined($@) and (length($@)>0) )
{
$s.="\n\ $@ error: ".$@;
}
writeerr($s);
return '';
}
# Get value for debugging.
eval {
$v=$cellin->value();
};
if ($@)
{
$s="$procname ERROR cell ".makecellname($row,$col).
": from XLSX sheetin->value. ";
writeerr($s);
usleep $optsleep;
}
my $bgcolor='';
if ($cellin)
{
my $format=$cellin->get_format();
my $fillref=$format->{Fill};
my @fillarr=@$fillref;
my $idx='';
if (defined($cellin->{Format}->{Fill}->[2]))
{
$idx=$cellin->{Format}->{Fill}->[2]; # Get background color index of this cell.
if ($idx=~m/^[\d]+$/)
{
$bgcolor=$wkbkin->color_idx_to_rgb($idx);
}
else {
$s="$procname ERROR cell ".makecellname($row,$col).": ".
"Background color was blank for index '$idx'.";
writeerr($s);
sleep 1;
}
}
#$font=$format->{Font}; # Returns font.
#my $idx=$font->{Color}; # Returns color index.
#my $rgbcolor=$ssin->ColorIdxToRGB(0,$idx); # Return RGB color as 6 ctr string.
$s="$procname: ".makecellname($row,$col)." background ='$bgcolor'".
". Val=$v";
debugprgif($s,' ');
}
else {
$s=$prefixsp."$procname ERROR ".makecellname($row,$col).", $xlsfnin: ".
", cell->get_format returned blank. ";
return ''; # Error, color not found.
}
return trim($bgcolor); # getcellcolor
}
The text was updated successfully, but these errors were encountered:
When using my code getcellcolor(), I get undef or garbage back that is meaningless. Here is my subroutine below.
The text was updated successfully, but these errors were encountered: