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


In reply to Changing cell property in Excel through a module by prasadbabu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.