For all these odd formatting issues in Excel, I've always found it useful to actually create the format in an excel spreadsheet first and then read that data with perl to see how it should be generated. | [reply] |
Alright, you've gotta be aware that in Excel you can dispaly formats of a cell any way you want so a cell accepts two different textual info, like a formatted "Example Name" followed by an unformatted <<Variable_input>> as in your example. But whether that can be done through Perl, I doubt, I can not recall anything in the Spredsheet::WriteExcel module documentation that testified to this conjecture, to avoid the alignment issues use the merge_range(); instead of write() method of $worksheet.. I have come up with this code, to show the merging thing, thus solving a part of your question, as for the other part, I had to circumvent my way around and make the variable display on the right of the cell and below the "Example Name" line
#!/usr/local/bin/perl
use strict;
use warnings;
use Spreadsheet::WriteExcel;
my $workbook=Spreadsheet::WriteExcel->new('excel.xls');
my $worksheet=$workbook->add_worksheet('');
my $var= "biohisham";
my $bold=$workbook->add_format(
bold=>1,
align=>'center',
valign=>'vcenter',
size=> 15 #font_size
);
my $var_format=$workbook->add_format(
align=>'left',
valign=>'right',
size=>15
);
$worksheet->set_column(0,1,30);
$worksheet->set_row($_, 30) for (1,2);
$worksheet->merge_range('A1:B2',"Example Name:", $bold);
$worksheet->merge_range('A3:B3',"\b$var", $var_format);
Excellence is an Endeavor of Persistence.
Chance Favors a Prepared Mind
| [reply] [d/l] |
@biohisham
Thanks for your answer.
Actually this is an existing file, where in I was supposed to fix few things.
I did not want to touch other cells using merge_range, but I guess I do not have any option.
I worked out the merge_range way, and my issue is resolved now.
Thanks once again!
| [reply] |