2 # conver_to_xls converts tab separated files to xls and is released
3 # under the terms of the GPL version 2, or any later version, at your
4 # option. See the file README and COPYING for more information.
5 # Copyright 2008 by Don Armstrong <don@donarmstrong.com>.
6 # $Id: perl_script 1153 2008-04-08 00:04:20Z don $
17 convert_to_xls - convert tab separated files to xls
21 convert_to_xls tsv_file1 [tsv_file2] [options] > foo.xls
24 --debug, -d debugging level (Default 0)
25 --help, -h display this help
26 --man, -m display manual
34 Debug verbosity. (Default 0)
38 Display brief useage information.
51 use Spreadsheet::WriteExcel;
56 my %options = (debug => 0,
62 'debug|d+','help|h|?','man|m');
64 pod2usage() if $options{help};
65 pod2usage({verbose=>2}) if $options{man};
67 $DEBUG = $options{debug};
71 push @USAGE_ERRORS,"You must give at least one file";
74 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
79 my $wb = Spreadsheet::WriteExcel->new(\*STDOUT) or die "Unable to create new spreadsheet";
80 for my $file (@FILES) {
81 my $fh = IO::File->new($file,'r') or die "Unable to open $file for reading: $!";
82 my $ws = $wb->add_worksheet($file) or die "Unable to create new worksheet";
86 my @row = map {s/^"//; s/"$//; $_} split /\t/,$_;
87 for my $col (0..$#row) {
88 $ws->write($row,$col+1,$row[$col]);