set_column()
セットを持つフォーマットオブジェクトでメソッドを使用する必要がありますbg_color
。ここに小さな実例があります。
#!/usr/bin/perl
use strict;
use warnings;
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new( 'columns.xls' );
my $worksheet = $workbook->add_worksheet();
# Add some formats with background colors.
my $format1 = $workbook->add_format( bg_color => 'yellow' );
my $format2 = $workbook->add_format( bg_color => 0x32 );
# Format column A with a background color of yellow.
$worksheet->set_column('A:A', undef, $format1);
# Format column c with a new width and light green.
$worksheet->set_column('C:C', 30, $format2);
# Add some data to the worksheet.
my $headings = [ 'Column 1', 'Column 2', 'Column 3' ];
my $data = [
[ 2, 3, 4, 5, 6, 7 ],
[ 1, 4, 5, 2, 1, 5 ],
[ 3, 6, 7, 5, 4, 3 ],
];
$worksheet->write( 'A1', $headings );
$worksheet->write( 'A2', $data );
__END__
次のような出力が得られます。