首页 / PERL / 用 Perl 读写 Excel 文件
用 Perl 读写 Excel 文件
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了用 Perl 读写 Excel 文件,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1405字,纯文字阅读大概需要3分钟。
内容图文
安装 Excel 模块的 PPM 命令
ppm> install OLE::Storage_Lite
ppm> install Spreadsheet::ParseExcel
ppm> install Spreadsheet::WriteExcel
Windows 示例:解析
#!/usr/bin/perl -w use strict; use Win32::OLE qw(in with); use Win32::OLE::Const ‘Microsoft Excel‘; $Win32::OLE::Warn = 3; # die on errors... # get already active Excel application or open new my $Excel = Win32::OLE->GetActiveObject(‘Excel.Application‘) || Win32::OLE->new(‘Excel.Application‘, ‘Quit‘); # open Excel file my $Book = $Excel->Workbooks->Open("c:/komodo projects/test.xls"); # You can dynamically obtain the number of worksheets, rows, and columns # through the Excel OLE interface. Excel‘s Visual Basic Editor has more # information on the Excel OLE interface. Here we just use the first # worksheet, rows 1 through 4 and columns 1 through 3. # select worksheet number 1 (you can also select a worksheet by name) my $Sheet = $Book->Worksheets(1); foreach my $row (1..4){ foreach my $col (1..3){ # skip empty cells next unless defined $Sheet->Cells($row,$col)->{‘Value‘}; # print out the contents of a cell printf "At ($row, $col) the value is %s and the formula is %s\n", $Sheet->Cells($row,$col)->{‘Value‘}, $Sheet->Cells($row,$col)->{‘Formula‘}; } } # clean up after ourselves $Book->Close;
$sheet->Cells($row, $col)->{‘Value‘} = 1;
原文:http://my.oschina.net/u/347414/blog/382976
内容总结
以上是互联网集市为您收集整理的用 Perl 读写 Excel 文件全部内容,希望文章能够帮你解决用 Perl 读写 Excel 文件所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。