简体   繁体   English

如何通过工作表名称读取 Perl 中的 Excel 文件

[英]How to read Excel file in Perl by sheet name

I am looking for some examples/advice on how to write a Perl script to read data from an Excel file by sheet name and not sheet number.我正在寻找一些关于如何编写 Perl 脚本以按工作表名称而不是工作表编号从 Excel 文件中读取数据的示例/建议。 This is an example with Spreadsheet , but it doesn't work with sheet name:这是Spreadsheet的示例,但不适用于工作表名称:

#Code Perl :
use Spreadsheet::Read qw(ReadData);
{
    my $book  = ReadData ("test.xls");
    my $sheet = $book->sheet ("name_3");
    my @rows = rows ($sheet);
    ...
} 

Can you help me please?你能帮我吗?

It works for me when I use the OO API :当我使用OO API时,它对我有用:

use warnings;
use strict;
use Spreadsheet::Read;

my $book  = Spreadsheet::Read->new('test.xls');
my $sheet = $book->sheet('Sheet1');
my @rows  = $sheet->rows();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM