【问题标题】:How to read excel sheet using perl script with simple check condition如何使用带有简单检查条件的 perl 脚本读取 excel 表
【发布时间】:2015-03-25 04:19:51
【问题描述】:

我是 perl 的新手,试图以简单的条件读取 excel 表..

问题是读取所有记录并检查 b 列是否有“Always null”字符串,如果是,则显示列“C”的输出

示例:始终为 Null 条件

预期输出:a,b,c,f,g

【问题讨论】:

    标签: perl


    【解决方案1】:
    #!/usr/bin/perl 
    
    use strict;
    use warnings;
    use v5.14;
    
    use Spreadsheet::ParseExcel;
    use Data::Dumper;
    
    my $ws = Spreadsheet::ParseExcel
                    ->new()
                    ->parse('yourfile.xls')
                    ->worksheet(0);
    
    my ($i, $r_max) = $ws->row_range;
    
    my ($cell_B, $cell_C);
    
    while ($i <= $r_max) {
        $cell_B = $ws->get_cell($i,1);
        $cell_C = $ws->get_cell($i,2);
    
        say $cell_C->value 
            if $cell_B 
                and $cell_C 
                and $cell_B->value eq 'Always null';
    } continue { $i++ }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-02
      • 1970-01-01
      • 2015-01-17
      • 1970-01-01
      • 1970-01-01
      • 2011-02-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多