清单 1:安装 Excel 模块的 PPM 命令
ppm> install OLE::Storage_Lite
ppm> install Spreadsheet::ParseExcel
ppm> install Spreadsheet::WriteExcel
总是报一下错误!!
Can't locate Spreadsheet/Read.pm in @INC (you may need to install the Spreadsheet::Read module) (@INC contains: C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .) at D:\201505\20150514\testr.pl line 5.
BEGIN failed--compilation aborted at D:\201505\20150514\testr.pl line 5.
后用以下程序测试通过:
#!/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("D:/201505/20150514/Book1.xlsx");
# 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;
别人引用的:如果您正在使用 Windows 机器,请坚持使用 Win32::OLE 模块,除非您的机器上根本没有 Excel。虽然 Spreadsheet::WriteExcel 和 Spreadsheet::ParseExcel 模块的功能正不断完善,但 Win32::OLE 是目前获得 Excel 数据的最简便方式。
在 UNIX,特别是 Linux 上,请使用 Spreadsheet::WriteExcel 和 Spreadsheet::ParseExcel 模块对 Excel 数据进行编程访问。
分享到:
相关推荐
perl脚本perl脚本perl脚本perl脚本
用Perl/Tkx写的genesis2000板边脚本
通过perl读写excel 通过perl读写excel 通过perl读写excel 通过perl读写excel
使用方法简单,在当前目录下,使用perl make_f.pl xx,xx为例化的filelist文件名,按下回车将会生成.f文件,里面列出了当前目录下所有.v文件的绝对路径,将脚本中.v替换成.c也可以检索当前目录下的所有.c文件,...
oracle数据库同步perl脚本示例 其中有2个文件,一个是 perl同步脚本,另一个是存储过程; 大致思路是:perl脚本从数据库A同步数据至库B的临时表中,再通过存储过程将库B中的临时数据过滤导入正式数据当中。
在Java中运行Perl脚本 JERL
利用perl读取EXCEL文件输出到XML文件
这是一个用perl语言解析的一个excel文件,将excel中的数据按照既定格式输出,方便数据处理
Perl是Practical Extraction and Report Language的缩写,它是由Larry Wall设计的,并由他不断更新和维护,用于在UNIX环境下编程。 .Perl具有高级语言(如C)的强大能力和灵活性。事实上,你将看到,它的许多特性是...
perl脚本学习范例
Perl学习笔记中的所有脚本文件,https://blog.csdn.net/zgezi/category_10259467.html
perl脚本自动生成UVM验证框架
perl脚本了解及学习,学会简单的perl脚本
编写的shell 脚本、perl 脚本、python 脚本 等如果不想被别人看到原文件,可以使用该工具shc ,对脚本文件加密,
linux加密perl 脚本工具
perl操作Excel示例perl操作Excel示例perl操作Excel示例perl操作Excel示例perl操作Excel示例perl操作Excel示例perl操作Excel示例perl操作Excel示例perl操作Excel示例....够20字了吗
适合Linux学习,Perl脚本开发基础学习,相信对你有帮助
perlperl Excel操作
materials studio 聚合物交联核心脚本
赛哦ifuowoe弱任务哦尔维尔哦温柔温柔品牌人哦 飞洒票房破而 分