免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4879 | 回复: 6
打印 上一主题 下一主题

perl模块在win7下安装求教 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-02-19 23:44 |只看该作者 |倒序浏览
我想用perl处理excel文件,网上查到了一种方法是需要安装IO::Scalar和Spreadsheet::Read模块。
我查到的win7下的安装方法如下:
ppm install dmake
perl Makefile.PL
dmake
dmake test
dmake install
但在dmake test步出现了下列问题:
t/10_basics.t .. Can't locate Test/NoWarnings.pm in @INC (@INC contains: D:\Soft
Ware\Program\Spreadsheet-Read-0.46\blib\lib D:\SoftWare\Program\Spreadsheet-Read
-0.46\blib\arch D:/Perl/site/lib D:/Perl/lib .) at t/10_basics.t line 7.
BEGIN failed--compilation aborted at t/10_basics.t line 7.
t/10_basics.t .. Dubious, test returned 2 (wstat 512, 0x200)
Failed 99/99 subtests
我本以为test只是个测试,不会影响下一步,就继续下一步。完成之后,编个程序,想调用ReadData ()函数,结果报错:
Parser for XLS is not installed at excel.pl line 4
劳烦perl爱好者们帮分析一下什么原因,多谢

论坛徽章:
0
2 [报告]
发表于 2012-02-20 09:26 |只看该作者
excel.pl的源码都不放上来
我不知道Spreadsheet::Read能不能出来2003以上的格式,我只处理过2000的格式是没问题的

论坛徽章:
0
3 [报告]
发表于 2012-02-20 10:06 |只看该作者
用CSV代替excel格式吧.

论坛徽章:
0
4 [报告]
发表于 2012-02-20 14:36 |只看该作者
回复 2# nsnake_cu


    #!/usr/bin/perl
    use Spreadsheet::Read;
    my $file = 'D:\\Learning\\Book1.xls'; #需要处理的文件
    my $spreadsheet = ReadData ($file) or die "$!";
    my $sheet_count = $spreadsheet->[0]{sheets} or die "No sheets in $file\n"; #记录有几个sheet

  for my $sheet_index (1 .. $sheet_count)
  {
  $sheet = $spreadsheet->[$sheet_index] or next;
   printf("%s - %2d: [%-s] %3d Cols, %5d Rows\n",
             $file,$sheet_index,$sheet->{label},$sheet->{maxcol},$sheet->{maxrow});
    for my $row (1 .. $sheet->{maxrow}) {
   print join "\t" => map {$sheet->{cell}[$_][$row] // "-" } 1 .. $sheet->{maxcol};
   print "\n"
                                         };
   }

这是源码

论坛徽章:
1
未羊
日期:2014-09-08 22:47:27
5 [报告]
发表于 2012-02-20 15:34 |只看该作者
本帖最后由 wxlfh 于 2012-02-20 15:36 编辑

写Excel文件用 Spreadsheet::WriteExcel,解析Excel文件用 Spreadsheet:arseExcel。

Windows环境用 Win32::OLE,特别方便。

另,Windows环境Perl可以用ActivePerl,装模块可以用 PPM。

论坛徽章:
0
6 [报告]
发表于 2012-02-20 15:57 |只看该作者
回复 3# zhh124


    我试了一下,csv格式的倒是可以读出来!

论坛徽章:
0
7 [报告]
发表于 2012-02-20 15:59 |只看该作者
回复 5# wxlfh


    多谢!但我还是没搞清楚dmake test为什么会报错?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP