Leser: 24
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
#!/usr/bin/perl use warnings; use strict; use Win32::OLE; sub PrintExcelSheet($); PrintExcelSheet("C:\\Lokale_Daten\\Mappe1.xls"); sub PrintExcelSheet($) { my $dateiXls = shift; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; my $excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); my $book = $excel->Workbooks->Open("$dateiXls"); $book->Worksheets(2)->PrintOut; $excel->Quit(); } # PrintExcelSheet
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 53 54 55
#!/usr/bin/perl use warnings; use strict; use Win32::OLE; sub PrintExcelSheet($); sub WelcheDatei($); my $pfad = "C:\\Lokale_Daten"; opendir(my $fhDir, $pfad) or die $!; my @files = grep { $_ =~ m/\.xls$/ } readdir($fhDir); closedir($fhDir) or die $!; WelcheDatei($pfad); sub WelcheDatei($) { my $pfad = shift; print "Welche der Dateien soll verwendet werden?: "; chomp(my $antw = <STDIN>); exit if not $antw; for my $i ( 1 .. 31 ) { my $dateiXls = $pfad."/".$i.".xls"; PrintExcelSheet($dateiXls) if $antw eq $i; } # for WelcheDatei($pfad); } # WelcheDatei sub PrintExcelSheet($) { my $dateiXls = shift; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; my $excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); my $book = $excel->Workbooks->Open("$dateiXls"); $book->Worksheets(2)->PrintOut; $excel->Quit(); } # PrintExcelSheet