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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.