sub StartUp { use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); my $vtfalse = Variant(VT_BOOL, 0); my $vttrue = Variant(VT_BOOL, 1); my $vtpagesw = Variant(VT_I4, 1); my $vtpagest = Variant(VT_I4, 999); eval {$ex = Win32::OLE->GetActiveObject('Excel.Application','Quit')}; die "Excel not installed" if $@; unless (defined $ex) { $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die "Oops, cannot start Excel"; } $ex->{visible} = 0; # Hide excel to the operator $ex->{DisplayAlerts}=0; # Stops the alerts of excel $ex->{SheetsInNewWorkbook} = 2; # Set the number of sheets in workbook $tb = $ex->Workbooks->Add; # Create the new workbook $sheet = $tb->WorkSheets(2); # Select the sheet $sheet->{Name}="Détailé"; # give the name of the report to the sheet $sheet->Activate(); # Set the Height and width $sheet->Rows("1")->{RowHeight}="47"; $sheet->Columns("A")->{ColumnWidth}="13,57"; $sheet->Columns("B")->{ColumnWidth}="9,43"; $sheet->Columns("C")->{ColumnWidth}="19"; # Set Vertical and Horizontal alignment $sheet->Columns("A:X")->{HorizontalAlignment} = xlCenter; $sheet->Rows("1:7")->{HorizontalAlignment} = xlLeft; with ($sheet->Range("D8:X8"), 'HorizontalAlignment' =>xlLeft, 'VerticalAlignment' => xlBottom, 'Orientation' => 60, 'WrapText' => $vtfalse, 'IndentLevel' => 0, 'ShrinkToFit' => $vtfalse, 'MergeCells' => $vtfalse, 'ReadingOrder' => xlContext) ; $sheet->Columns("D:P")->{ColumnWidth} = "3,14"; $sheet->Columns("Q:Y")->{ColumnWidth} = "5,29"; $sheet->Columns("D:X")->{NumberFormat}="0"; # Set the "style" $sheet->Range("A2:A3")->Font->{size} = 12; $sheet->Range("A2:A3")->Font->{bold} = 1; $sheet->Range("8:8")->Font->{bold} = 1; with ($sheet->Range("8:8")->Borders(xlEdgeBottom), 'Weight' =>xlMedium, 'LineStyle' => xlContinuous, 'ColorIndex' => xlAutomatic) ; # Write the cells that never change Ins("A2", "Campagne:"); Ins("A3", "Rapport:"); Ins("A5", "Journée d\'appel:"); Ins("A6", "Date du rapport:"); #Split the screen and freeze pane $ex->ActiveWindow->{SplitRow} = 8; $ex->ActiveWindow->{FreezePanes} = 1; with ($sheet->PageSetup, 'FitToPagesWide'=>$vtpagesw, 'FitToPagesTall'=>$vtpagest, 'Zoom'=>$vtfalse, 'PrintGridlines'=>0, 'LeftHeader'=> "", 'CenterHeader' => "", 'RightHeader' => "", 'LeftFooter' => "&IPerformance des agents - Détail - journée de traitement: ".DuAu($ARGV[0],$ARGV[1]), 'CenterFooter' => "", 'Orientation' => xlLandscape, 'RightFooter' => "&IPage &P de &T.", 'PrintHeadings'=>0, 'FirstPageNumber'=> xlAutomatic, 'PaperSize' => xlPaperLetter, 'PrintTitleRows' => "8:8", 'LeftMargin' => $ex->Application->InchesToPoints(0.196850393700787), 'RightMargin' => $ex->Application->InchesToPoints(0.196850393700787), 'TopMargin' => $ex->Application->InchesToPoints(0.196850393700787), 'BottomMargin' => $ex->Application->InchesToPoints(0.393700787401575), 'HeaderMargin' => $ex->Application->InchesToPoints(0.196850393700787), 'FooterMargin' => $ex->Application->InchesToPoints(0.196850393700787), 'CenterHorizontally' => $vttrue );