Leser: 23
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
#!/usr/bin/perl use warnings; use strict; use Win32::OLE qw( in with ); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; my $excelfile = 'test.xls'; my $excel = Win32::OLE -> GetActiveObject( 'Excel.Application' ) || Win32::OLE -> new( 'Excel.Application', 'Quit' ); $excel -> {DisplayAlerts} = 0; $excel -> {Visible} = 0; $excel -> {SheetsInNewWorkBook} = 1; my $workbook = $excel -> Workbooks -> Add(); my $sheet = $workbook -> Worksheets( 1 ); $sheet -> Activate; $sheet -> {Name} = 'Tabelle_Eins'; $sheet -> Range( 'A1' ) -> {Value} = 5; $sheet -> Range( 'A2' ) -> {Value} = '=IF(A5>3, "Yes", "No")'; $workbook -> SaveAs( { Filename => $excelfile, FileFormat => xlWorkbookNormal } ); $workbook -> Close; $excel -> Quit; undef $workbook; undef $excel;
1
2
3
C:\Dokumente und Einstellungen\m\Eigene Dateien>perl win32.pl
Win32::OLE(0.1709) error 0x80020009: "Ausnahmefehler aufgetreten"
in PROPERTYPUT "Value" at win32.pl line 23
$sheet -> Range( 'A2' ) -> {Value} = ['=IF(A5>3, "Yes", "No")'];
$sheet -> Range( 'A2B3' ) -> {Value} = $arrayref;
$sheet -> Range( 'A2' ) -> {Value} = '=WENN(A5>3; "Yes"; "No")';
1
2
Win32::OLE(0.1709) error 0x800a03ec
in METHOD/PROPERTYGET "Add" at C:\Dokumente und Einstellungen\m\Eigene Dateien\test.pl line 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 29 30
#!C:\Perl\bin\perl.exe use warnings; use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; my $excelfile = 'test.xls'; my $excel = Win32::OLE -> GetActiveObject( 'Excel.Application' ) || Win32::OLE -> new( 'Excel.Application', 'Quit' ); $excel -> {DisplayAlerts} = 0; my $workbook = $excel -> Workbooks -> Add(); my $sheet = $workbook -> Worksheets( 1 ); $sheet -> Range( 'A1' ) -> {Value} = 'Enter an integer between 1 and 10'; my $range1 = $sheet -> Range( 'B1' ); $range1 -> Validation -> Add( { Type => xlValidateWholeNumber, AlertStyle => xlValidAlertStop, Operator => xlBetween, Formula1 => 1, Formula2 => 10 } ); $sheet -> Range( 'A3' ) -> {Value} = 'Select a value from a drop down list'; my $range2 = $sheet -> Range( 'B3' ); $range2 -> Validation -> Add( { Type => xlValidateList, AlertStyle => xlValidAlertStop, Operator => xlBetween, Formula1 => [ qw( open high close ) ] } ); # macroaufzeichnung : .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= xlBetween, Formula1:="open; high; close" $workbook -> SaveAs( $excelfile ); $workbook -> Close;
1 2 3 4 5 6
$range -> Validation -> Add( { Type => xlValidateList, AlertStyle => xlValidAlertStop, Operator => xlBetween, Formula1 => "open; high; close" } );