指定EXCEL文件的各種格式

返回

# excel_format.pl # use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use utf8; # set perl's OLE module to return Unicode Win32::OLE->Option(CP => Win32::OLE::CP_UTF8, Warn=>3); use Encode; my(%t); # use existing instance if Excel is already running eval {$t{ex} = Win32::OLE->GetActiveObject('Excel.Application')}; die "Excel not installed" if $@; unless (defined $t{ex}) { $t{ex} = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die "Oops, cannot start Excel"; } #$t{ex}->{Visible} = 1; # 顯示EXCEL $t{ex}->{DisplayAlerts} = 'False'; # get a new workbook $t{book} = $t{ex}->Workbooks->Add; # write to a particular cell $t{sheet} = $t{book}->Worksheets(1); $t{sheet}->Cells(2,2)->{Font}->{Name} = "MS 明朝"; $t{sheet}->Cells(2,2)->{Value} = "日本富士山"; $t{sheet}->Cells(3,2)->{Font}->{Size} = "9"; $t{sheet}->Cells(3,2)->{Font}->{Bold} = "False"; #$t{sheet}->Cells(3,2)->{WrapText} = "True"; $t{sheet}->Cells(3,2)->{Value} = "1983"; with ($t{sheet}->Range("B3"), HorizontalAlignment => xlLeft ); # save and exit $t{excel} = "試験データ.xls"; $t{excel} = encode("utf8",$t{excel}); $t{excel} = decode("utf8",$t{excel}); $t{book}->SaveAs($t{excel}); undef $t{book}; undef $t{ex};
返回
邯郸市| 临洮县| 洛扎县| 颍上县| 丰顺县| 平泉县| 威海市| 安西县| 香港| 昌江| 尤溪县| 江北区| 环江| 依安县| 罗定市| 仲巴县| 客服| 宁安市| 文安县| 四平市| 卢氏县| 邵东县| 许昌市| 资兴市| 东丰县| 萨迦县| 龙口市| 高淳县| 基隆市| 永善县| 吴川市| 河间市| 双牌县| 延长县| 乌拉特中旗| 公主岭市| 福贡县| 怀远县| 武隆县| 友谊县| 渝中区|