Thread Excel Win32::OLE Formel (15 answers)
Opened by Gast at 2009-10-31 17:58

Gast Gast
 2009-11-06 19:54
#127951 #127951
Thx, jetzt geht's:

Code (perl): (dl )
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
#!C:\Perl\bin\perl.exe
use warnings;
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3;
my $xl = Win32::OLE::Const -> Load( 'Microsoft Excel' );
my $excelfile = 'C:\Dokumente und Einstellungen\m\Eigene Dateien\win32_ole_excel.xls';
my $excel = Win32::OLE -> GetActiveObject( 'Excel.Application' ) || Win32::OLE -> new( 'Excel.Application', 'Quit' ) or die $!;

$excel->{ReferenceStyle} = $xl->{xlR1C1}; #  Z1S1-Bezugsart

my $workbook = $excel -> Workbooks -> Add();
my $sheet = $workbook -> Worksheets( 1 );
$sheet -> Activate;

$sheet->Range( 'A3' )->{Value} = 3;
$sheet->Range( 'B3' )->{FormulaR1C1} = '=WENN( ZS(-1) > 5; "OK"; "Not OK")';

$sheet->Range( 'G1' )->{Value} = 3;
$sheet->Range( 'G2' )->{Value} = 7;
$sheet->Range( 'G3' )->{Value} = 6;
$sheet->Range( 'G4' )->{FormulaR1C1} = '=SUMME(Z(-3)S:Z(-1)S)';


$workbook -> SaveAs( { Filename => $excelfile, FileFormat => xlWorkbookNormal } );


(Namen für die Bezugsart hatte ich schon alle mit eval und zwei for-Schleifen durchprobiert.)

View full thread Excel Win32::OLE Formel