Leser: 1
6 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#! /usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcel;
my $workbook = new Spreadsheet::WriteExcel('hallo.xls');
die "Problems creating new Excel file: $!" unless defined $workbook;
my $sheet = $workbook -> add_worksheet();
my $format= $workbook -> add_format(num_format => '[red][>10]General;[blue][<10]General;[green]General');
$sheet -> write(0, 0, 100, $format);
$sheet -> write(0, 1, 10, $format);
$sheet -> write(0, 2, 5, $format);
$workbook -> close() or die "Error closing file: $!";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#! /usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $workbook = new Spreadsheet::WriteExcel('hallo.xls'); die "Problems creating new Excel file: $!" unless defined $workbook; my $sheet = $workbook -> add_worksheet(); my $cell = 0; for( 100, 10, 5 ){ my $format= $workbook -> add_format(); my $color = 'green'; if( $_ < 10 ){ $color = 'red'; } elsif( $_ > 10 ){ $color = 'blue'; } $format->set_bg_color( $color ); $sheet -> write(0, $cell++, $_, $format); } $workbook -> close() or die "Error closing file: $!";
Gast+2008-03-26 20:05:06--(kleiner Wermutstropfen: man kann damit keine Formatvorlagen erstellen.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#! /usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $workbook = new Spreadsheet::WriteExcel('hallo.xls'); die "Problems creating new Excel file: $!" unless defined $workbook; my $sheet = $workbook -> add_worksheet(); my $green = $workbook -> add_format( bg_color => 'green' ); my $blue = $workbook -> add_format( bg_color => 'blue' ); my $red = $workbook -> add_format( bg_color => 'red' ); my $cell = 0; for( 100, 10, 5, 30 ){ my $format = $green; if( $_ < 10 ){ $format = $red; } elsif( $_ > 10 ){ $format = $blue; } $sheet -> write(0, $cell++, $_, $format); } $workbook -> close() or die "Error closing file: $!";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#! /usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $workbook = new Spreadsheet::WriteExcel('hallo.xls'); die "Problems creating new Excel file: $!" unless defined $workbook; my $sheet = $workbook -> add_worksheet(); my $format= $workbook -> add_format(); $format -> set_num_format('[red][>50]General;[blue][<50]General;[green]General'); my $format_title= $workbook -> add_format(); $format_title -> set_font('Arial'); $format_title -> set_size(14); # usw. $sheet -> set_row(0, 20, $format_title); foreach my $row (1..10){ foreach my $col (0..1){ $sheet -> write($row, $col, undef); } my $r = $row + 1; $sheet -> write($row, 2, "=A$r+B$r", $format); } $workbook -> close() or die "Error closing file: $!";
6 Einträge, 1 Seite |