指定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};
返回
青冈县| 亳州市| 沿河| 阜新| 建德市| 耿马| 诸城市| 静安区| 青铜峡市| 汝州市| 大新县| 大余县| 商南县| 新和县| 潼南县| 绥棱县| 齐齐哈尔市| 鲁甸县| 桐城市| 嘉峪关市| 翁源县| 博湖县| 铁岭市| 新营市| 贵溪市| 岳普湖县| 邵东县| 千阳县| 浮梁县| 葫芦岛市| 重庆市| 三都| 大埔区| 蛟河市| 栖霞市| 东至县| 永康市| 株洲县| 荆门市| 织金县| 绥德县|