6 Einträge, 1 Seite |
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!usr/bin/perl -w
use strict;
use warnings;
my $IN = "daten.txt";
my $OUT = "auswertung.xls";
use Spreadsheet::WriteExcel;
open IN, "<$IN" or die "Fehler beim Oeffnen von $IN";
my @eintraege = ();
while(<IN>) {
chomp;
my($frage, $antwort) = split /+/, $_, 2;
$antwort ||= "";
push @entries, [$frage, $antwort];
}
close IN;
my $xlsdat = Spreadsheet::WriteExcel->new($OUT);
my $sheet = $xlsdat->addworksheet();
for my $col (0..2) {
for my $row (0..220) {
my $e = shift @entries;
last unless $e;
my($frage, $antwort) = @$e;
# Eintrag schreiben
$sheet->write($row, 2*$col,
"$frage - $antwort");
}
}
for my $col (0..2) {
$sheet->set_column(2*$col, 2*$col);
}
$xlsdat->close();
1
2
3
4
5
6
7
8
9
10
11
12
set_v_pagebreaks(@breaks)
Add vertical page breaks to a worksheet. A page break causes all the data that follows it to be printed on the next page. Vertical page breaks act between columns. To create a page break between columns 20 and 21 you must specify the break at column 21. However in zero index notation this is actually column 20. So you can pretend for a small while that you are using 1 index notation:
$worksheet1->set_v_pagebreaks(20); # Break between column 20 and 21
The set_v_pagebreaks() method will accept a list of page breaks and you can call it more than once:
$worksheet2->set_v_pagebreaks( 20, 40, 60, 80, 100); # Add breaks
$worksheet2->set_v_pagebreaks(120, 140, 160, 180, 200); # Add some more
Note: If you specify the ``fit to page'' option via the fit_to_pages() method it will override all manual page breaks.
1
2
3
4
5
6
7
8
9
10
11
12
13
my($frage, $antwort) = @$e;
# Eintrag schreiben
#---------- So könnte es gehen! ------------
if ($frage =~ /^###BREAK###/) {
set_v_pagebreaks( $row++ );
next;
}
#----------
$sheet->write($row, 2*$col,
"$frage - $antwort");
6 Einträge, 1 Seite |