Hello
I'm trying use write_rich_string to write a mixed format string passed to it as a scalar variable.
What I would like to see are the red brackets in the following
[128-A-G-snp;147-CTGTCA-GAGTCC-complex 41.0]
However, what I do see is
$red,'[','128-A-G-snp;147-CTGTCA-GAGTCC-complex 41.5',$red,'] '
my$hyperlink_format = $workbook->add_format(
color => 'blue',
underline => 1,
);
my$red=$workbook->add_format( color => 'red' );
my$row_cnt=@$rows;
my$col_cnt=@{$$rows[0]};
for (my$i=0;$i<$row_cnt;$i++){
for (my$j=0;$j<$col_cnt;$j++){
if (($j == 3) && ($i != 0)){
$worksheet->write( $i, $j, $$rows[$i][$j] , $hyperlink_format, 'alignment' );
print LOG "makeExcel: \$\$rows[$i][$j]\t$$rows[$i][$j]\n";
}elsif((($j == 6)||($j == 8)||($j == 10)) && ($i != 0)){
my@row=split "]",$$rows[$i][$j];
my@row_markup=();
for my$group (@row){
if ($group=~/^\[(.+)/){
push(@row_markup,"\$red,'[','$1',\$red,'] '");
}
}
my$row_markup=join '',@row_markup;
print LOG "\$worksheet->write_rich_string($i, $j, $row_markup)\n";
$worksheet->write_rich_string($i, $j, $row_markup);
#$worksheet->write_rich_string($i, $j, $red,'[','128-A-G-snp;147-CTGTCA-GAGTCC-complex 41.0',$red,']');
}else{
$worksheet->write( $i, $j, $$rows[$i][$j] );
}
}
}
From my log file:
$ grep write_rich_string log
$worksheet->write_rich_string(1, 6, $red,'[','1 100.0',$red,'] ')
$worksheet->write_rich_string(1, 8, $red,'[','147-CTGTCA-GAGTCC-complex 44.0',$red,'] ')
$worksheet->write_rich_string(1, 10, $red,'[','128-A-G-snp;147-CTGTCA-GAGTCC-complex 41.5',$red,'] ')
Note that when I uncomment the hard-coded line in the code (and comment out the line above it, I get the result I desire, namely read brackets.
So it seems like write_rich_string is not interpolating the interpolating $row_markup.
Is there an error in my syntax, a different function for this purpose, or does Excel::Writer::XLSX simly not do it?
Thanks very much for your help.
Mark