#!/usr/bin/perl #~ Converter Script for XLS to TSV. Handles Multiple Tabs into separa +te files. #~ (c)2004 Anima Legato <l3gatosan@gmail.com> #~ #~ This code is redistributable and modifiable under the same terms as + Perl #~ itself. use strict; use warnings; use Spreadsheet::ParseExcel::Simple; use File::Spec; for (@ARGV) { for (glob $_) { next unless m/\.xls$/i; next unless -r $_; dump_books($_); } } sub dump_books { my ($vol, $path, $file) = File::Spec->splitpath(shift); my $eBook = Spreadsheet::ParseExcel::Simple->read(File::Spec->catp +ath($vol,$path,$file)); unless (defined $eBook) { warn "Can't open Spreadsheet in file $file (@".File::Spec->cat +path($vol,$path,$file)."\n"; return undef; } my @sheet = $eBook->sheets; for (0..@sheet-1) { next unless $sheet[$_]->has_data(); my $sfn = $file; $sfn =~ s?\.xls$??i; $sfn.= ((@sheet > 1) ? sprintf(".%02i",$_) : "").'.tab'; open TAB, '>', $sfn or do { warn "Unable to write to $sfn"; next; }; while ($sheet[$_]->has_data) { my @row = $sheet[$_]->next_row; print TAB join("\t",@row)."\n"; } } } ##--dump_books--##

In reply to xls2tab - Simple MS Excel to TSV converter by legato

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.