r75509 - in /branches/upstream/libspreadsheet-read-perl/current: Changes META.yml README Read.pm examples/ss2tk examples/xls2csv examples/xlscat
periapt-guest at users.alioth.debian.org
periapt-guest at users.alioth.debian.org
Sun Jun 12 14:16:45 UTC 2011
Author: periapt-guest
Date: Sun Jun 12 14:16:37 2011
New Revision: 75509
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=75509
Log:
[svn-upgrade] new version libspreadsheet-read-perl (0.42)
Modified:
branches/upstream/libspreadsheet-read-perl/current/Changes
branches/upstream/libspreadsheet-read-perl/current/META.yml
branches/upstream/libspreadsheet-read-perl/current/README
branches/upstream/libspreadsheet-read-perl/current/Read.pm
branches/upstream/libspreadsheet-read-perl/current/examples/ss2tk
branches/upstream/libspreadsheet-read-perl/current/examples/xls2csv
branches/upstream/libspreadsheet-read-perl/current/examples/xlscat
Modified: branches/upstream/libspreadsheet-read-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/Changes?rev=75509&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/Changes (original)
+++ branches/upstream/libspreadsheet-read-perl/current/Changes Sun Jun 12 14:16:37 2011
@@ -1,4 +1,10 @@
Revision history for Spreadsheet::Read
+
+0.42 Wed 01 Jun 2011
+
+ - Add --html output option to xlscat
+ - Force CSV parser when in-sep is given
+ - Prefer Data::Peek over Data::Dumper if available
0.41 Wed 06 Oct 2010
Modified: branches/upstream/libspreadsheet-read-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/META.yml?rev=75509&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/META.yml (original)
+++ branches/upstream/libspreadsheet-read-perl/current/META.yml Sun Jun 12 14:16:37 2011
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Read
-version: 0.41
+version: 0.42
abstract: Meta-Wrapper for reading spreadsheet data
license: perl
author:
@@ -10,7 +10,7 @@
provides:
Spreadsheet::Read:
file: Read.pm
- version: 0.41
+ version: 0.42
requires:
perl: 5.006
Exporter: 0
@@ -18,16 +18,15 @@
Data::Dumper: 0
configure_requires:
ExtUtils::MakeMaker: 0
-build_requires:
- perl: 5.006
+test_requires:
Test::Harness: 0
Test::More: 0.88
Test::NoWarnings: 0
recommends:
- perl: 5.010001
+ perl: 5.012003
File::Temp: 0.22
IO::Scalar: 0
- Test::More: 0.96
+ Test::More: 0.98
resources:
license: http://dev.perl.org/licenses/
repository: http://repo.or.cz/w/Spreadsheet-Read.git
@@ -40,16 +39,16 @@
requires:
Text::CSV_XS: 0.69
recommends:
- Text::CSV: 1.19
- Text::CSV_PP: 1.27
- Text::CSV_XS: 0.75
+ Text::CSV: 1.21
+ Text::CSV_PP: 1.29
+ Text::CSV_XS: 0.83
opt_excel:
description: Provides parsing of Microsoft Excel files
requires:
Spreadsheet::ParseExcel: 0.26
Spreadsheet::ParseExcel::FmtDefault: 0
recommends:
- Spreadsheet::ParseExcel: 0.58
+ Spreadsheet::ParseExcel: 0.59
opt_excelx:
description: Provides parsing of Microsoft Excel 2007 files
requires:
Modified: branches/upstream/libspreadsheet-read-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/README?rev=75509&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/README (original)
+++ branches/upstream/libspreadsheet-read-perl/current/README Sun Jun 12 14:16:37 2011
@@ -59,7 +59,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2005-2010 H.Merijn Brand
+Copyright (C) 2005-2011 H.Merijn Brand
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Modified: branches/upstream/libspreadsheet-read-perl/current/Read.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/Read.pm?rev=75509&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/Read.pm (original)
+++ branches/upstream/libspreadsheet-read-perl/current/Read.pm Sun Jun 12 14:16:37 2011
@@ -23,7 +23,7 @@
use strict;
use warnings;
-our $VERSION = "0.41";
+our $VERSION = "0.42";
sub Version { $VERSION }
use Carp;
@@ -1045,7 +1045,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2005-2010 H.Merijn Brand
+Copyright (C) 2005-2011 H.Merijn Brand
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Modified: branches/upstream/libspreadsheet-read-perl/current/examples/ss2tk
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/examples/ss2tk?rev=75509&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/examples/ss2tk (original)
+++ branches/upstream/libspreadsheet-read-perl/current/examples/ss2tk Sun Jun 12 14:16:37 2011
@@ -1,7 +1,7 @@
#!/pro/bin/perl
# ss2tk: show SpreadSheet file in Tk::TableMatrix::Spreadsheet (*)
-# (m)'07 [26-06-2007] Copyright H.M.Brand 2005-2010
+# (m)'07 [26-06-2007] Copyright H.M.Brand 2005-2011
use strict;
use warnings;
Modified: branches/upstream/libspreadsheet-read-perl/current/examples/xls2csv
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/examples/xls2csv?rev=75509&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/examples/xls2csv (original)
+++ branches/upstream/libspreadsheet-read-perl/current/examples/xls2csv Sun Jun 12 14:16:37 2011
@@ -1,7 +1,7 @@
#!/pro/bin/perl
# xls2csv: Convert Microsoft Excel spreadsheet to CSV
-# (m)'08 [10-03-2008] Copyright H.M.Brand 2008-2010
+# (m)'08 [10-03-2008] Copyright H.M.Brand 2008-2011
use strict;
use warnings;
Modified: branches/upstream/libspreadsheet-read-perl/current/examples/xlscat
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/examples/xlscat?rev=75509&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/examples/xlscat (original)
+++ branches/upstream/libspreadsheet-read-perl/current/examples/xlscat Sun Jun 12 14:16:37 2011
@@ -1,12 +1,12 @@
#!/pro/bin/perl
# xls2cat: show XLS/SXC file as Text
-# (m)'09 [13-05-2009] Copyright H.M.Brand 2005-2010
+# (m)'11 [03-02-2011] Copyright H.M.Brand 2005-2011
use strict;
use warnings;
-our $VERSION = "1.9";
+our $VERSION = "2.1";
sub usage
{
@@ -39,6 +39,8 @@
" Output CSV:\n",
" -c Output CSV, separator = ','\n",
" -m Output CSV, separator = ';'\n",
+ " Output HTML:\n",
+ " -H Output HTML\n",
" Selection:\n",
" -S <sheets> Only print sheets <sheets>. 'all' is a valid set\n",
" Default only prints the first sheet\n",
@@ -64,6 +66,7 @@
my $opt_v = 0; # Verbosity for xlscat
my $opt_d = 0; # Debug level for Spreadsheet::Read
my $opt_A = 0; # Show field colors in ANSI escapes
+my $opt_H = 0; # Output in HTML
my $clip = 1;
my $enc_i; # Input encoding
my $enc_o; # Output encoding
@@ -75,6 +78,7 @@
"c|csv" => sub { $opt_c = "," },
"m|ms" => sub { $opt_c = ";" },
"insepchar".
+ "|in-sep".
"|in-sep-char=s" => \$sep,
# Input XLS
@@ -85,6 +89,7 @@
"i|index" => \$opt_i,
"s|separator".
"|outsepchar".
+ "|out-sep".
"|out-sep-char=s" => \$opt_s,
"S|sheets=s" => \$opt_S,
"R|rows=s" => \$opt_R,
@@ -96,6 +101,7 @@
"u|unformatted" => \$opt_u,
"v|verbose:1" => \$opt_v,
"d|debug:1" => \$opt_d,
+ "H|html:1" => \$opt_H,
"noclip" => sub { $clip = 0 },
# Encoding
@@ -112,7 +118,10 @@
$opt_i && $opt_R and usage 1, "Options i and R are mutually exclusive";
$opt_i && $opt_C and usage 1, "Options i and C are mutually exclusive";
$opt_i && $opt_F and usage 1, "Options i and F are mutually exclusive";
+$opt_i && $opt_H and usage 1, "Options i and H are mutually exclusive";
$opt_c && $opt_s and usage 1, "Options c and s are mutually exclusive";
+$opt_c && $opt_H and usage 1, "Options c and H are mutually exclusive";
+$opt_s && $opt_H and usage 1, "Options s and H are mutually exclusive";
defined $opt_s or $opt_s = "|"; eval "\$opt_s = qq{$opt_s}";
defined $opt_S or $opt_S = $opt_i ? "all" : "1";
@@ -128,9 +137,19 @@
});
}
-use Data::Dumper; # I should use Data::Peek instead
- $Data::Dumper::Sortkeys = 1;
- $Data::Dumper::Indent = 1;
+# Debugging. Prefer Data::Peek over Data::Dumper if available
+{ use Data::Dumper;
+ my $dp = 0;
+ eval q{
+ use Data::Peek;
+ $dp = 1;
+ };
+ sub ddumper
+ {
+ $dp ? DDumper (@_)
+ : print STDERR Dumper (@_);
+ } # ddumper
+ }
@ARGV or usage 1;
my $file = shift;
@@ -139,18 +158,29 @@
use Encode qw( encode decode );
use Spreadsheet::Read;
+
if ($opt_c) {
Spreadsheet::Read::parses ("csv") or die "No CSV module found\n";
- eval { use Text::CSV_XS };
+ eval q{use Text::CSV_XS};
+ }
+if ($opt_H) {
+ $enc_o = "utf-8";
+ $opt_H = sub { $_[0]; };
+ eval q{
+ use HTML::Entities;
+ $opt_H = sub {
+ encode_entities (decode ("utf-8", $_[0]));
+ };
+ };
}
my @RDarg = (debug => $opt_d, clip => $clip);
$opt_A and push @RDarg, "attr" => 1;
-defined $sep and push @RDarg, "sep" => $sep;
+defined $sep and push @RDarg, "sep" => $sep, parser => "csv";
defined $dtfmt and push @RDarg, "dtfmt" => $dtfmt;
$opt_v > 4 and print STDERR "ReadData ($file, @RDarg);\n";
my $xls = ReadData ($file, @RDarg) or die "cannot read $file\n";
-$opt_v > 7 and print STDERR Dumper ($xls);
+$opt_v > 7 and ddumper ($xls);
my $sc = $xls->[0]{sheets} or die "No sheets in $file\n";
$opt_v > 1 and print STDERR "Opened $file with $sc sheets\n";
@@ -194,8 +224,52 @@
"\e[${attr}m";
} # ansi_color
+sub css_color
+{
+ my ($fg, $bg, $bold, $ul, $ha) = @_;
+
+ my @css;
+ $bold and push @css, "font-weight: bold";
+ $ul and push @css, "text-decoration: underline";
+ $fg and push @css, "color: $fg";
+ $bg and push @css, "background: $bg";
+ $ha and push @css, "text-align: $ha";
+
+ local $" = "; ";
+ @css ? qq{ style="@css"} : "";
+ } # css_color
+
binmode STDERR, ":utf8";
$enc_o and binmode STDOUT, ":encoding($enc_o)";
+
+if ($opt_H) {
+ print <<EOH;
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title>$file</title>
+ <meta name="Author" content="xlscat $VERSION" />
+ <style type="text/css"><!--
+ body, h2,
+ td, th { font-family: "Nimbus Sans L", "DejaVu Sans",
+ Helvetica, Arial, sans; }
+ table { border-spacing: 2px;
+ border-collapse: collapse; }
+ td, th { vertical-align: top;
+ padding: 4px; }
+ table > tbody > tr > th,
+ table > tr > th {
+ background: #e0e0e0; }
+ table > tbody > tr > td:not([class]),
+ table > tr > td:not([class]) {
+ background: #f0f0f0; }
+ .odd { background: #e0e0e0; }
+ --></style>
+ </head>
+<body>
+EOH
+ }
my $name_len = 30;
if ($opt_i) {
@@ -211,7 +285,7 @@
exists $print{sheet}{$si} or next;
$opt_v > 1 and print STDERR "Opening sheet $si ...\n";
my $s = $xls->[$si] or next;
- $opt_v > 5 and print STDERR Dumper ($s);
+ $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]);
@@ -239,8 +313,9 @@
eval "\$print{col} = [ map { \$_ - 1 } $cols ]";
$nc = @{$print{col}};
}
- $opt_v >= 8 and print Dumper (\%print);
-
+ $opt_v >= 8 and ddumper (\%print);
+
+ $opt_H and print qq{<h2>$sn</h2>\n\n<table border="1">\n};
my $undef = $opt_v > 2 ? "-- undef --" : "";
my ($h, @w) = (0, (0) x $nc); # data height, -width, and default column widths
my @align = ("") x $nc;
@@ -254,7 +329,7 @@
} $s->{cell}[$_][$r], $s->{$cell};
$opt_v > 2 and print STDERR "$_:$r '$uval' / '$fval'\n";
$opt_A and
- push @att, [ @{$s->{attr}[$_][$r]}{qw( fgcolor bgcolor bold uline )} ];
+ push @att, [ @{$s->{attr}[$_][$r]}{qw( fgcolor bgcolor bold uline halign )} ];
defined $s->{cell}[$_][$r] ? $opt_u ? $uval : $fval : "";
} $c[0] .. $c[1];
exists $print{col} and @row = @row[@{$print{col}}];
@@ -265,8 +340,19 @@
$row[$c] =~ m/\D/ and $align[$c] = "-";
}
}
+ if ($enc_o) { $_ = encode ($enc_o, $_) for @row; }
+ if ($opt_H) { # HTML
+ print " <tr>";
+ foreach my $c (0 .. $#row) {
+ my $css = css_color (@{$att[$c]});
+ $r % 2 and $css .= qq{ class="odd"};
+ my $td = $opt_H->($row[$c]);
+ print "<td$css>$td</td>";
+ }
+ print "</tr>\n";
+ next;
+ }
if ($opt_c) { # CSV
- if ($enc_o) { $_ = encode ($enc_o, $_) for @row; }
$opt_c->print (*STDOUT, \@row) or die $opt_c->error_diag;
next;
}
@@ -290,6 +376,7 @@
} continue {
++$h % 100 or printf STDERR $v_fmt, $nc, $h, "\r";
}
+ $opt_H and print " </table>\n\n";
printf STDERR $v_fmt, $nc, $h, "\n";
$opt_L or next;
if ($opt_n) {
@@ -310,3 +397,4 @@
printf $fmt, @row;
}
}
+$opt_H and print "</body>\n</html>\n";
More information about the Pkg-perl-cvs-commits
mailing list