better usps suffix handling
[migration-tools.git] / xlsx2tab
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 xlsx2tab
9
10 =head1 SUMMARY
11
12 Quick-and-dirty filter lifted from the Spreadsheet::XSLX POD
13 to convert the first sheet of an Excel .xlsx file to TSV
14
15 =head1 USAGE
16
17 xlsx2tab foo.xlsx > foo.tsv
18
19 =cut
20
21 use Spreadsheet::XLSX;
22 use Text::Iconv;
23 my $converter = Text::Iconv->new ("utf-8", "windows-1251");
24  
25 my $excel = Spreadsheet::XLSX->new ($ARGV[0], $converter);
26  
27 foreach my $sheet (@{$excel->{Worksheet}}) {
28     $sheet->{MaxRow} ||= $sheet->{MinRow};
29     foreach my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) {
30         print join("\t", map { $_->unformatted() } @{ $sheet->{Cells}[$row] }), "\n";
31     }
32     last; # only look at the first worksheet for now
33 }