【问题标题】:How to read data from XLSX file having data from more than 256 columns如何从包含超过 256 列数据的 XLSX 文件中读取数据
【发布时间】:2013-11-20 07:02:47
【问题描述】:

如何从包含超过 256 列数据的 XLSX 文件中读取数据

尝试使用 Spreadsheet::XLSX cpan perl 库模块,但如果我们尝试读取包含 400 多列(超过 256 列)数据的 XLSX 文件,则不会成功。

请有任何建议。

【问题讨论】:

    标签: perl parsing cpan xlsx


    【解决方案1】:

    我使用 Excel 2010 创建了一个 XLSX 文件,第一行包含 1403,并将其放入 Spreadsheet::XLSX 的示例代码中。它有效:

    use Spreadsheet::XLSX;
    my $excel = Spreadsheet::XLSX->new( 'Mappe3.xlsx', );
    
    foreach my $sheet ( @{ $excel->{Worksheet} } ) {
      printf( "Sheet: %s\n", $sheet->{Name} );
      $sheet->{MaxRow} ||= $sheet->{MinRow};
      foreach my $row ( $sheet->{MinRow} .. $sheet->{MaxRow} ) {
        $sheet->{MaxCol} ||= $sheet->{MinCol};
        foreach my $col ( $sheet->{MinCol} .. $sheet->{MaxCol} ) {
          my $cell = $sheet->{Cells}[$row][$col];
          if ($cell) {
            printf( "( %s , %s ) => %s\n", $row, $col, $cell->{Val} );
          }
        }
      }
    }
    
    __END__
    
    Sheet: Tabelle1
    ( 0 , 0 ) => 1
    ( 0 , 1 ) => 2
    ( 0 , 2 ) => 3
    [..] # snipped
    ( 0 , 252 ) => 253
    ( 0 , 253 ) => 254
    ( 0 , 254 ) => 255
    ( 0 , 255 ) => 256
    ( 0 , 256 ) => 257
    [..] # snipped
    ( 0 , 398 ) => 399
    ( 0 , 399 ) => 400
    ( 0 , 400 ) => 401
    ( 0 , 401 ) => 402
    ( 0 , 402 ) => 403
    Sheet: Tabelle2
    Sheet: Tabelle3
    

    您应该发布您正在使用的代码和您看到的错误消息。否则我们无法重现问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      • 1970-01-01
      • 2019-08-18
      • 2021-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多