2006년 12월 12일 화요일

txt2xls 관련

> #!/opt/bin/perl5.6 -w
> ############################################################################
> ###
> # Example of how to use the WriteExcel module
> # Program to convert a text [delim] separated value file into an Excel file.
> # Usage: txt2xls.pl file.txt newfile.xls
>
> use Getopt::Long;
> use Spreadsheet::WriteExcel::Big;
>
> GetOptions ("d=s" => \$delim);
> $delim = "|" if !defined($delim);
> $delim =~ s/\|/\\|/g;
>
> # Check for valid number of arguments
> if (($#ARGV < 1) || ($#ARGV > 2)) {
>    die("Usage: txt2xls file.txt newfile.xls\n");
> };
>
> # Open the Comma Seperated Variable file
> open (TXTFILE, $ARGV[0]) or die "$ARGV[0]: $!";
>
> # Create a new Excel workbook
> my $workbook  = Spreadsheet::WriteExcel::Big->new($ARGV[1]);
> my $worksheet = $workbook->add_worksheet();
>
> # Row and column are zero indexed
> my $row = 0;
>
> while (<TXTFILE>) {
>     chomp;
>     @cols = split(/\s*${delim}\s*/,$_);
>
>     $col = 0;
>     foreach my $token (@cols) {
>             $worksheet->write($row, $col, $token);
>             $col++;
>     }
>     $row++;
> }

I'm trying to get this script to work.  I can't find the
Spreadsheet::WriteExcel::Big module.  I can find
Spreadsheet::WriteExcel::Simple and am trying to
get that to work right now.

I can find the Spreadsheet::WriteExcel::Big
module in google:
http://search.cpan.org/dist/Spreadsheet-WriteExcel/
and wonder why ActiveState does not list it.

I'll probably figure it out, but am open to any
suggestions anybody might have.

I'm using the latest Perl on Win2000.


Mike Flannigan
mikeflan@earthlink.net

댓글 없음:

댓글 쓰기