File Coverage

blib/lib/Spreadsheet/PrintExcelSheet.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Spreadsheet::PrintExcelSheet;
2            
3 1     1   47358 use warnings;
  1         115  
  1         33  
4 1     1   5 use strict;
  1         3  
  1         35  
5 1     1   429 use Win32::OLE;
  0            
  0            
6            
7             our $VERSION = '0.02';
8            
9             BEGIN {
10             use Exporter;
11             our @ISA = qw( Exporter );
12             our @EXPORT = qw( );
13             our %EXPORT_TAGS = ( );
14             our @EXPORT_OK = qw( &PrintIt );
15             }
16            
17             sub PrintIt($@) {
18            
19             my ($dateiXls, @sheetNr) = @_;
20            
21             my $sheetNr = "@sheetNr";
22            
23             use Win32::OLE qw(in with);
24             use Win32::OLE::Const 'Microsoft Excel';
25            
26             $Win32::OLE::Warn = 3;
27            
28             my $excel = Win32::OLE->GetActiveObject('Excel.Application') ||
29             Win32::OLE->new('Excel.Application', 'Quit');
30            
31             my $book = $excel->Workbooks->Open("$dateiXls");
32             my $sheet = $book->Worksheets;
33            
34             if ($sheetNr eq 'all') {
35             for my $worksheet (in ($sheet)) {
36             $worksheet->PrintOut;
37             } # for
38             } # if
39             else {
40             for my $i (@sheetNr) {
41             $book->Worksheets($i)->PrintOut;
42             } # for
43             } # else
44            
45             $excel->Quit();
46            
47             } # PrintIt
48            
49            
50             1;
51             __END__