VBA ==> Perl变换

戻る

------------------------------------------------------------------------- Sub Macro2() ' ' Macro2 Macro ' Range("E11:I11").Select With Selection.Borders(xlEdgeBottom) .LineStyle = xlDouble .Weight = xlThick .ColorIndex = xlAutomatic End With Selection.Borders(xlEdgeRight).LineStyle = xlNone Selection.Borders(xlInsideVertical).LineStyle = xlNone End Sub -----------------------------------> $t{sheet}->Range("E11:I11")->Borders(xlEdgeBottom)->{LineStyle} = xlDouble; ------------------------------------------------------------------------- 安装Microsoft的Microsoft Visual Basic Microsoft Formsオブジェクトリファレンス ==>メソッド ==>Add マルチ ページ コントロール、タブ ストリップ コントロールの場合 Set Object = object.Add( [ Name [, Caption [, index]]]) その他のコントロールの場合 Set Control = object.Add( ProgID [, Name [, Visible]]) ------------------------------------------------------------------------- $ex = Win32::OLE->new('Excel.Application') or die "oops\n"; ------------------------------------------------------------------------- $ex->Amethod("arg")->Bmethod->{'Property'} = "foo"; ------------------------------------------------------------------------- $ex->Cmethod(undef,undef,$Arg3); ------------------------------------------------------------------------- # EXCELを起動 $t{ex} = Win32::OLE->new('Excel.Application') or die "oops\n"; # 「xxへの変更を保存しますか?」が出ない $t{ex}->{DisplayAlerts} = 'False'; $t{book} = $t{ex}->Workbooks->Add; $t{sheet} = $t{book}->Worksheets(1); $t{sheet}->Cells(2,2)->{Value} = "This is a dog."; $t{sheet}->Cells(3,3)->{Value} = "That is alos a dog"; # $ex->Cmethod(undef,undef,$Arg3); $t{book}->SaveAs("C:\\seki\\chubu\\jouetsu\\test\\ttt.xls"); #$t{ex}->{Visible} = 1; # 表示する $t{ex}->quit(); ------------------------------------------------------------------------- $ex->Dmethod($RequiredArg1, {NamedArg1 => $Value1, NamedArg2 => $Value2} ------------------------------------------------------------------------- # write a 2 rows by 3 columns range $t{sheet}->Range("A8:C9")->{Value} = [[ undef, 'Xyzzy', 'Plugh'], [ 42, 'Perl', 3.1415]]; # print # <undef>|Xyzzy|Plugh| # 42|Perl|3.1415| $array = $t{sheet}->Range("A8:C9")->{Value}; for (@$array) { for (@$_) { print defined($_) ? "$_|" : "<undef>|"; } print "\n"; } ------------------------------------------------------------------------- use Win32::OLE::Enum; ---------------------------------------------------------------- # 追加BOOK my $book = $excel->Workbooks->add() ; #取得SHEET my $sheet = $book->ActiveSheet; #写数据 $sheet->Range("B1")->{Value} = "OLE Sample" ; #取得数据 my $data = $sheet->Range("B1")->{Value}; print "(" . $data . ")\r\n"; #取得数据 my $array = $sheet->Range("A1:C1")->{Value}; print "(" . $$array[0][1] . ")\r\n"; # @@$arrayの2次元配列 #指定颜色 $sheet->Range("A1")->Interior->{ColorIndex} = 6; #指定颜色 $sheet->Range("A8:G8")->Interior->{ColorIndex} = 6; #划线 #Const xlContinuous = 1; $sheet->Range("C2")->Borders(xlDiagonalUp)->{LineStyle} = 1; $sheet->Range("C3")->Borders(xlDiagonalDown)->{LineStyle} = 1; #改变宽度 $sheet->Columns("A:A")->{ColumnWidth} = 4.00; #返回有效 $sheet->Range("A1")->{WrapText} = 1;
戻る