From 0445ca1b7fb163fd20346fedaaa7e8612f8f93c3 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 13 Apr 2010 00:19:06 +0000 Subject: [PATCH] NAME xlsx2tab SUMMARY Quick-and-dirty filter lifted from the Spreadsheet::XSLX POD to convert the first sheet of an Excel .xlsx file to TSV USAGE xlsx2tab foo.xlsx > foo.tsv --- xlsx2tab | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) create mode 100755 xlsx2tab diff --git a/xlsx2tab b/xlsx2tab new file mode 100755 index 0000000..8467ecd --- /dev/null +++ b/xlsx2tab @@ -0,0 +1,33 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +=head1 NAME + +xlsx2tab + +=head1 SUMMARY + +Quick-and-dirty filter lifted from the Spreadsheet::XSLX POD +to convert the first sheet of an Excel .xlsx file to TSV + +=head1 USAGE + +xlsx2tab foo.xlsx > foo.tsv + +=cut + +use Spreadsheet::XLSX; +use Text::Iconv; +my $converter = Text::Iconv->new ("utf-8", "windows-1251"); + +my $excel = Spreadsheet::XLSX->new ($ARGV[0], $converter); + +foreach my $sheet (@{$excel->{Worksheet}}) { + $sheet->{MaxRow} ||= $sheet->{MinRow}; + foreach my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) { + print join("\t", map { $_->unformatted() } @{ $sheet->{Cells}[$row] }), "\n"; + } + last; # only look at the first worksheet for now +} -- 1.7.2.5