Leser: 8
|< 1 2 3 4 5 ... 8 >| | 72 Einträge, 8 Seiten |
1
2
3
Warning: Content-Type header not found in the script output. If this script is not a CGI one, please use the Run -> Run in Command Prompt menu to run it.
Can't locate Text/CSV/Separator.pm in @INC (@INC contains: M:\sabrina C:/Perl/lib C:/Perl/site/lib .) at blubb.pl line 3.
BEGIN failed--compilation aborted at excel.pl line 3
Can't locate Spreadsheet/ParseExcel/Simple.pm in @INC (@INC contains: M:\sabrina C:/Perl/lib C:/Perl/site/lib .)at blubb.pl line 4.
1
2
3
Warning: Content-Type header not found in the script output. If this script is not a CGI one, please use the Run -> Run in Command Prompt menu to run it.
Can't locate Text/CSV/Separator.pm in @INC (@INC contains: M:\sabrina C:/Perl/lib C:/Perl/site/lib .) at blubb.pl line 3.
BEGIN failed--compilation aborted at excel.pl line 3
Can't locate Spreadsheet/ParseExcel/Simple.pm in @INC (@INC contains: M:\sabrina C:/Perl/lib C:/Perl/site/lib .)at blubb.pl line 4.
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
50
51
52
#!/usr/bin/perl
use strict;
use warnings;
use Spreadsheet::SimpleExcel;
my @data;
my $file = 'mailbox.txt';
my $delimiter = '\s{2,}|\t|\\';
my $columns = 2;
my $xls_file = 'zieldatei.xls';
my $excel = Spreadsheet::SimpleExcel->new();
$excel->add_worksheet('Test');
open(my $fh,'<',$file) or die $!;
while(my $line = <$fh>) { # alles was unten in __DATA__ steht symbolisiert eine Datei
chomp $line;
my @array = (split(/$delimiter/,$line))[0..($columns-1)];
foreach (@array) {
s%^\s+%%g; # fuehrende und
s%\s+$%%g; # abschliessende Blanks entfernen
} # foreach
push(@data,[@array]);
} # while
close $fh;
my $format = '';
for my $i(0..scalar(@{$data[0]})-1){
my $max = find_longest(map{$_->[$i]}@data);
$format .= '%-'.$max.'s ';
}
for my $entry(@data){
print sprintf($format . "<<\n",@$entry);
$excel->add_row('Test',$entry);
}
$excel->output_to_file($xls_file);
sub find_longest{
my $longest = 0;
for(@_){
my $length = length($_);
$longest = $length if($length > $longest);
}
return $longest;
}
perl -MSpreadsheet::SimpleExcel -e 1
Error: No valid repositories: Error:500 Can´t connect to ppm.ActiveState.com:80 <connect: Unknown error>
|< 1 2 3 4 5 ... 8 >| | 72 Einträge, 8 Seiten |