Click here to get back home

Spreadsheet::WriteExcel format width

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Spreadsheet::WriteExcel format width David Lao 05-20-2005
Posted by David Lao on May 20, 2005, 1:04 pm
Please log in for more thread options


Hi,

I tried to format the width of the columns but the value did not take.
When I open the perl.xls file, I saw the columns default to 10 for the
width. Do you know why ?

Here is the snippet of the code:

use Spreadsheet::WriteExcel;

# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new("perl.xls");

# Add a worksheet
$worksheet = $workbook->add_worksheet();

# Add and define a format
$format = $workbook->add_format(); # Add a format
$format->set_bold();
$format->set_color('black');
$format->set_align('center');

# Write a formatted and unformatted string, row and column
notation.
$col = $row = 0;

#=================================================
# Write header information
#=================================================

$worksheet->set_column($row, $col, 30);
$worksheet->write($row, $col, "BUG", $format);

$worksheet->set_column($row, 1, 10);
$worksheet->write($row, 1, "Owner", $format);

$worksheet->set_column($row, 2, 20);
$worksheet->write($row, 2, "Activity Name", $format);

$worksheet->set_column($row, 3, 30);
$worksheet->write($row, 3, "Subject", $format);

$worksheet->set_column($row, 4, 30);
$worksheet->write($row, 4, "Variant", $format);

$worksheet->set_column($row, 5, 10);
$worksheet->write($row, 5, "Detailed Description", $format);

$worksheet->set_column($row, 6, 10);
$worksheet->write($row, 6, "Test Procedure", $format);


Thanks,

David



Posted by Gary E. Ansok on May 20, 2005, 8:26 pm
Please log in for more thread options


>Hi,
>
>I tried to format the width of the columns but the value did not take.
>When I open the perl.xls file, I saw the columns default to 10 for the
>width. Do you know why ?
>
>Here is the snippet of the code:
>
> $worksheet->set_column($row, $col, 30);

Check the documentation for Spreadsheet::WriteExcel. The set_column method
looks like this:

set_column($first_col, $last_col, $width, $format, $hidden, $level)

It doesn't take a row number. I suspect you want

$worksheet->set_column($col, $col, 30);

- Gary Ansok


Posted by David Lao on May 20, 2005, 1:56 pm
Please log in for more thread options


Hi Gary,

It works after consulted with the documentation.
Thanks for your helps.

David



Similar ThreadsPosted
Spreadsheet::WriteExcel December 7, 2005, 3:50 pm
ANNOUNCE: Spreadsheet::WriteExcel 2.04 August 19, 2004, 12:05 am
Query about Spreadsheet::WriteExcel September 10, 2004, 3:54 pm
ANNOUNCE: Spreadsheet::WriteExcel 2.10 September 24, 2004, 12:52 am
Spreadsheet::WriteExcel and Frames October 11, 2004, 1:08 pm
Spreadsheet::WriteExcel new($var) not working May 20, 2008, 6:10 am
Proposal: String::Format::General December 1, 2006, 11:04 am
Proposal: String::Format::General December 2, 2006, 1:53 pm
Proposal: String::Format::General December 2, 2006, 2:56 pm
Proposal - AnyData::Format::Excel April 7, 2007, 10:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap