Leser: 10
|< 1 2 3 >| | 22 Einträge, 3 Seiten |
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
#!/usr/bin/perl use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; my $xl = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); $xl->{'Visible'} = 0; $xl->{'DisplayAlerts'} = 0; my $book = $xl->Workbooks->Open('c:\test.xls'); my $sheet = $book->Worksheets(1); my $last_row = $sheet->UsedRange->Find( { What => "*", SearchDirection => xlPrevious, SearchOrder => xlByRows } )->{Row}; print "Start Speed Test..\n"; my $current_time = time; my $time_start = $current_time; foreach my $y (1..$last_row) { foreach my $x ('a'..'j') { my $bla = $sheet->Range($x.$y)->{Value}; } if ((time - $current_time) >= 1) { $current_time = time; my $speed = sprintf("%.2f", ($y / ($current_time - $time_start))); print "$speed Zeilen pro Sekunde\n" unless (($current_time - $time_start) == 0); } } $xl->Workbooks->Quit(); $xl->destroy();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
%Time ExclSec CumulS #Calls sec/call Csec/c Name
0.00 9.218 9.642 56101 0.0002 0.0002 Win32::OLE::Dispatch
0.00 5.943 5.943 168296 0.0000 0.0000 Win32::OLE::Tie::Fetch
0.00 3.512 4.071 56098 0.0001 0.0001 Win32::OLE::DESTROY
0.00 2.370 12.488 56101 0.0000 0.0002 Win32::OLE::AUTOLOAD
0.00 1.962 7.905 168296 0.0000 0.0000 Win32::OLE::Tie::FETCH
0.00 0.476 0.476 56102 0.0000 0.0000 UNIVERSAL::isa
0.00 0.223 0.223 56098 0.0000 0.0000 Win32::OLE::Tie::DESTROY
0.00 0.219 0.357 1 0.2191 0.3572 Win32::OLE::Const::_Typelibs
0.00 0.138 0.138 564 0.0002 0.0002 Win32::OLE::Const::_Typelib
0.00 0.030 0.046 4 0.0075 0.0115 Config::BEGIN
0.00 0.016 0.016 1 0.0160 0.0160 Win32::OLE::Const::_Constants
0.00 0.016 0.016 2 0.0080 0.0080 Exporter::as_heavy
0.00 0.016 0.016 6 0.0027 0.0026 ActiveState::Path::BEGIN
0.00 0.015 0.450 5 0.0030 0.0899 main::BEGIN
0.00 0.000 0.000 1 0.0000 0.0000 Config::launcher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
my $parse_excel = Spreadsheet::ParseExcel->new(
CellHandler => \&cell_handler,
NotSetCell => 1,
);
my $workbook = $parse_excel->Parse('file.xls');
sub cell_handler {
my($workbook, $sheet_index, $row, $col, $cell) = @_;
# Skip some worksheets and rows (more efficiently).
if ($sheet_index > 2 and $row > 9) {
$workbook->ParseAbort(1);
return;
}
# Do something with the formatted cell value
print $cell->{_Value}, "\n";
}
QuoteVielleicht ist folgende Seite für dich ganz interessant:
http://perlmonks.org/index.p....=379743
Der Artikel erklärt deine Probleme und stellt Lösungen vor.
Code
#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
my $parse_excel = Spreadsheet::ParseExcel->new(
CellHandler => \&cell_handler,
NotSetCell => 1,
);
my $workbook = $parse_excel->Parse('file.xls');
sub cell_handler {
my($workbook, $sheet_index, $row, $col, $cell) = @_;
# Skip some worksheets and rows (more efficiently).
if ($sheet_index > 2 and $row > 9) {
$workbook->ParseAbort(1);
return;
}
# Do something with the formatted cell value
print $cell->{_Value}, "\n";
}
^ letztes Beispiel aus dem Artikel
MfG
|< 1 2 3 >| | 22 Einträge, 3 Seiten |