#!perl -w use warnings; use strict; ## Author: Devin Austin ## Excel to Text script ## very simple script... ## enter file name and get going! ## Usage: convert.pl ## Thanks to GrandFather for pretty much re-factoring my original code ## into this version. ## mostly straight out of the docs... use Spreadsheet::ParseExcel; my $oExcel = new Spreadsheet::ParseExcel; my $dir = $ARGV[1]; chomp $dir; unless (-d $dir) { print "Can't find directory $dir"; exit; } my $filename = "$dir/$ARGV[0]"; chomp $filename; unless (-e $filename) { print "Can't find file $filename"; exit ; } my $fullfilename = "$filename.txt"; ## start work print "Converting..."; #1.1 Normal Excel97 open E2T, ">", $fullfilename or die $!; my $oBook = Spreadsheet::ParseExcel::Workbook->Parse($filename); my($iR, $iC, $oWkS, $oWkC); foreach my $oWkS (@{$oBook->{Worksheet}}) { print "--------- SHEET:", $oWkS->{Name}, "\n"; print E2T $oWkS->{Name}, "|"; next unless defined $oWkS->{MinRow} and defined $oWkS->{MaxRow}; for my $iR ($oWkS->{MinRow} .. $oWkS->{MaxRow}) { for my $iC ($oWkS->{MinCol} .. $oWkS->{MaxCol}) { $oWkC = $oWkS->{Cells}[$iR][$iC]; next if ! defined $oWkC; print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC); print E2T $oWkC->Value, "|"; } } print E2T "\n"; } close E2T; print "Finished!"; exit;