prasadbabu has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks, I am using Spreadsheet::WriteExcel for some data generation.
In the first column of the Excel sheet i need the numbers with 5 digits. When i generated that using sprintf function, it is not generating as 5 digit.
Anyhow i accomplished my job by just converting it into a string by concatenating a space, rather a number. I know this is not the proper way. Is there anyother way to do it.
We can do manually by just changing the cell property, number to text. But by using Spreadsheet::WriteExcel i cannot able to change. Is there a propery in this module to do that, or is it not possible to change by this module?
This is the code i tried.
use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new("PIIgenerator2.xls"); my $isbn = $ARGV[0]; my $worksheet = $workbook->add_worksheet("Revises"); my %font = ( -font => 'Arial', -size => 12, -color => 'black', -bold => 1, ); my $format = $workbook->add_format(%font); $worksheet->write('A1', "ISBN"); $worksheet->write('B1', "$isbn"); $worksheet->write('A2', "Article ID", $format); $worksheet->write('B2', "ISBN", $format); $worksheet->write('C2', "PII", $format); $worksheet->write('D2', "Comments", $format); #my $format1 = $workbook->set_num_format(); my $s; for $a (3..10) { $s = sprintf("%05d",($a-2)); my $s1 = "$s".' '; $worksheet->write("A$a", "$s1"); }
Thanks in advance
Prasad
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Changing cell property in Excel through a module
by gopalr (Priest) on Sep 21, 2005 at 06:41 UTC | |
|
Re: Changing cell property in Excel through a module
by jmcnamara (Monsignor) on Sep 21, 2005 at 08:12 UTC | |
|
Re: Changing cell property in Excel through a module
by runrig (Abbot) on Sep 21, 2005 at 06:05 UTC |