Spreadsheet-Read
view release on metacpan or search on metacpan
# Catch weirdness like $SPREADSHEET_READ_XLSX = "DBD::Oracle"
$can{$format} = "!$preset is not supported for the $format format";
next;
}
if (eval "local \$_; require $preset" and not $@) {
# forcing a parser should still check the version
my $ok;
my $has = $preset->VERSION;
$has =~ s/_[0-9]+$//; # Remove beta-part
if ($min_version =~ m/^v([0-9.]+)/) { # clumsy versions
my @min = split m/\./ => $1;
$has =~ s/^v//;
my @has = split m/\./ => $has;
$ok = (($has[0] * 1000 + $has[1]) * 1000 + $has[2]) >=
(($min[0] * 1000 + $min[1]) * 1000 + $min[2]);
}
else { # normal versions
$ok = $has >= $min_version;
}
$ok or $preset = "!$preset";
}
else {
$preset = "!$preset";
maxrow => 0,
maxcol => 0,
cell => [],
attr => [],
merged => [],
active => 1,
hidden => 0,
},
);
for (split m/\s*[\r\n]\s*/, $txt) {
if (m/^dimension.*of ([0-9]+) rows.*of ([0-9]+) columns/i) {
@{$data[1]}{qw(maxrow maxcol)} = ($1, $2);
next;
}
s/^r([0-9]+)c([0-9]+)\s*=\s*// or next;
my ($c, $r) = map { $_ + 1 } $2, $1;
if (m/.* \{(.*)}$/ or m/"(.*)"/) {
my $cell = cr2cell ($c, $r);
$opt{rc} and $data[1]{cell}[$c][$r] = $1;
$opt{cells} and $data[1]{$cell} = $1;
examples/ss-dups-tk.pl view on Meta::CPAN
)->pack (qw(-side left -expand 1 -fill both));
{ my $opt_S = @opt_S ? join ",", @opt_S : 1;
$bf->Label (
-text => "Sheet(s)",
)->pack (qw(-side left -expand 1 -fill both));
$bf->Entry (
-textvariable => \$opt_S,
-width => 10,
-validate => "focusout",
-vcmd => sub {
@opt_S = grep m/\S/, split m/\s*,\s*/ => $opt_S;
1;
},
)->pack (qw(-side left -expand 1 -fill both));
}
{ my $opt_R = join ",", @opt_R;
$bf->Label (
-text => "Rows(s)",
)->pack (qw(-side left -expand 1 -fill both));
$bf->Entry (
-textvariable => \$opt_R,
-width => 10,
-validate => "focusout",
-vcmd => sub {
@opt_R = grep m/\S/, split m/\s*,\s*/ => $opt_R;
1;
},
)->pack (qw(-side left -expand 1 -fill both));
}
{ my $opt_C = join ",", @opt_C;
$bf->Label (
-text => "Columns(s)",
)->pack (qw(-side left -expand 1 -fill both));
$bf->Entry (
-textvariable => \$opt_C,
-width => 10,
-validate => "focusout",
-vcmd => sub {
@opt_C = grep m/\S/, split m/\s*,\s*/ => $opt_C;
1;
},
)->pack (qw(-side left -expand 1 -fill both));
}
sub ranges (@) {
my @g;
foreach my $arg (@_) {
for (split m/,/, $arg) {
if (m/^(\w+)\.\.(\w+)$/) {
my ($s, $e) = ($1, $2);
$s =~ m/^[1-9]\d*$/ or ($s, $e) = (qq("$s"), qq("$e"));
eval "push \@g, $s .. $e";
}
else {
push @g, $_;
}
}
}
scripts/xlscat view on Meta::CPAN
}
my $name_len = 30;
if ($opt_i) {
my $nl = 0;
foreach my $sn (keys %{$xls->[0]{sheet}}) {
length ($sn) > $nl and $nl = length $sn;
}
$nl and $name_len = $nl;
}
my @opt_F = split m/[^A-Z\d]+/ => $opt_F;
foreach my $si (1 .. $sc) {
my @data;
exists $print{sheet}{$si} or next;
$opt_v > 1 and warn "Opening sheet $si ...\n";
my $s = $xls->[$si] or next;
$opt_v > 5 and ddumper ($s);
my @r = (1, $s->{maxrow});
my @c = (1, $s->{maxcol});
my ($sn, $nr, $nc) = ($s->{label}, $r[-1], $c[-1]);
scripts/xlscat view on Meta::CPAN
++$h % 100 == 0 && $opt_v && $v_fmt and printf STDERR $v_fmt, $nc, $h, "\r";
}
$opt_H and print " </table>\n\n";
$v_fmt && $v_fmt and printf STDERR $v_fmt, $nc, $h, "\n";
if ($sort_order) {
my @o;
my @h;
$sort_order =~ s/\+([0-9]+)\b// and @h = splice @data, 0, $1;
for ($sort_order =~ m/([0-9]+[rn]*)/g) {
m/^([0-9]+)(.*)/;
push @o, { col => $1 - 1, map { $_ => 1 } split m// => $2 };
}
my $sort = sub {
my $d = 0;
foreach my $o (@o) {
my ($A, $B) = map { $_->[0][$o->{col}] || 0 } $a, $b;
$d = $o->{n}
? $o->{r} ? $B <=> $A : $A <=> $B
: $o->{r} ? $B cmp $A : $A cmp $B
and return $d;
}
scripts/xlsx2csv view on Meta::CPAN
my $m = $ENV{NO_COLOR} ? "Pod::Text" : "Pod::Text::Color";
my $p = $m->new ();
open my $fh, ">", \my $out;
$p->parse_from_file ($0, $fh);
close $fh;
print $out;
exit 0;
} # pod_text
sub pod_nroff {
first { -x "$_/nroff" } grep { -d } split m/:+/ => $ENV{PATH} or pod_text ();
require Pod::Man;
my $p = Pod::Man->new ();
open my $fh, "|-", "nroff", "-man";
$p->parse_from_file ($0, $fh);
close $fh;
exit 0;
} # pod_nroff
unless ($xls) {
( run in 0.581 second using v1.01-cache-2.11-cpan-5511b514fd6 )