use warnings; use strict; use Cwd; use OLE; use Win32::OLE::Const "Microsoft Excel"; &init; sub init { my $directory = &getcwd; &edit_excel ( "$directory/TemplateAuswertung.xlsx" ); } sub edit_excel { my ( $xl_report ) = @_; my ( $excel, $workbook, $sheet, $row ); $excel = CreateObject OLE 'Excel.Application'; $excel -> {Visible} = 1; $workbook = $excel -> Workbooks -> Open ( "$xl_report" ) or &terminate ( "open $xl_report" ); #$sheet = $workbook -> Worksheets -> Add ( { After => $workbook -> Worksheets ( $workbook -> Worksheets -> {Count} ) } ); $sheet = $workbook -> Worksheets(1); $sheet -> Activate(); $sheet -> Range ( "A:B" ) -> Font -> {size} = 10; $sheet -> Range ( "C:D" ) -> Font -> {Size} = 10; $sheet -> Range ( "A:D" ) -> Font -> {Bold} = "True"; $sheet -> Range ( "A:D" ) -> {HorizontalAlignment} = xlHAlignLeft; $sheet -> Range ( "C11" ) -> {HorizontalAlignment} = xlHAlignCenter; $sheet -> Range ( "C13" ) -> {HorizontalAlignment} = xlHAlignCenter; $sheet -> Range ( "D11" ) -> {HorizontalAlignment} = xlHAlignCenter; $sheet -> Range ( "D13" ) -> {HorizontalAlignment} = xlHAlignCenter; #$sheet -> Range ( "A18" ) -> {Value} = "CAN Signal"; #$sheet -> Range ( "B18" ) -> {Value} = "PASSED"; #$sheet -> Range ( "C18" ) -> {Value} = "No Comment"; #$sheet -> Range ( "D18" ) -> {Value} = "RAS"; $sheet -> Range ( "A2" ) -> Activate; $excel -> ActiveWindow -> {FreezePanes} = "True"; #$sheet -> {Name} = "Test Report" . $workbook -> Worksheets -> {Count}; $excel -> {DisplayAlerts} = 0; # $workbook -> SaveAs ( "$xl_report" ); $workbook -> Save; $workbook -> Close; #$excel -> Quit; } sub terminate { print "\a\a\nCould not @_ for the following reason:\n\n$!\n"; print "This program will now terminate. Press to exit."; ; exit; }