Thread Excel und Win32::OLE --> Spaltenbreite und Sortier (18 answers)
Opened by Teutales at 2006-05-03 17:21

Teutales
 2006-05-03 17:21
#65529 #65529
User since
2006-03-21
47 Artikel
BenutzerIn
[default_avatar]
Hallo, folgende Funktion ist erfolgreich im Einsatz, allerdings würde ich gerne die Spalte C breiter machen und nach Spalte A sortieren. Leider habe ich keine Dokumention gefunden, aus der das hervorgeht. Kann mir jemand nen Tip geben? Danke schonmal!

Code: (dl )
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
46
47
48
49
sub createExcel {

# Lokale Variaben:
my @toDo = @_;
my $EVAL_ERROR;
my $excel;
my $book;
my $sheet;

showLine();
print "FUNCTION createExcel\n";

print "Try to open Excel.\n";

# falls Instanz von Excel schon läuft benutze diese:
eval {$excel = Win32::OLE->GetActiveObject('Excel.Application')};
return 1 if $EVAL_ERROR;

#wenn $excel noch nichts zugewiesen starte Excel:
unless (defined $excel) {
$excel = Win32::OLE->new('Excel.Application') #, sub {$_[0]->Quit;}
or return 1;
}
print "Excel ok.\n";

# Excel sichtbar/unsichtbar machen
$excel->{Visible} = 1;

# Erzeuge leere Tabelle:
$book = $excel->Workbooks->Add;
$sheet = $book->Worksheets(1);

print "Write to File. \n";

my $length = @toDo;
if ($length eq 0) {
$sheet->Cells(1,1)->{Value} = "Keine passenden Einträge gefunden!";
}
else {
for (my $i=0; $i<$length; $i++) {
$sheet->Cells($i+1,1)->{Value} = $toDo[$i][0];
$sheet->Cells($i+1,2)->{Value} = $toDo[$i][3];
$sheet->Cells($i+1,3)->{Value} = $toDo[$i][1];
$sheet->Cells($i+1,4)->{Value} = $toDo[$i][2];
$sheet->Cells($i+1,5)->{Value} = $toDo[$i][4];
}
}
return 0;
}

View full thread Excel und Win32::OLE --> Spaltenbreite und Sortier