| Server IP : 50.21.180.56 / Your IP : 216.73.216.139 Web Server : Apache System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux User : ws67922704 ( 67922704) PHP Version : 8.5.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /kunden/usr/share/doc/libspreadsheet-parseexcel-perl/examples/sample/ |
Upload File : |
#!/usr/bin/perl
#!/usr/bin/perl
use strict;
use warnings;
use Spreadsheet::ParseExcel;
use Getopt::Long qw(GetOptions);
my $file;
my $help;
my $dump;
my ($row, $col);
GetOptions(
"file=s" => \$file,
"help" => \$help,
"dump" => \$dump,
"row=i" => \$row,
"col=i" => \$col,
) or usage();
usage() if $help;
usage() if not $file;
my $excel = Spreadsheet::ParseExcel::Workbook->Parse($file);
if ($dump) {
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});
}
}
}
}
}
if (defined $row and defined $col) {
foreach my $sheet (@{$excel->{Worksheet}}) {
printf("Sheet: %s\n", $sheet->{Name});
my $cell = $sheet->{Cells}[$row][$col];
printf("( %s , %s ) => '%s'\n", $row, $col, $cell->{Val});
printf("( %s , %s ) => '%s'\n", $row, $col, $cell->Value);
}
}
sub usage {
print <<"END_USAGE";
Usage: $0
--file FILENAME
--dump
--row ROW
--col COL
--help
END_USAGE
exit;
}