-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparse-excel.pl
More file actions
executable file
·48 lines (40 loc) · 1.26 KB
/
parse-excel.pl
File metadata and controls
executable file
·48 lines (40 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
my $oExcel = new Spreadsheet::ParseExcel;
die "You must provide a filename to $0 to be parsed as an Excel file" unless @ARGV;
my $oBook = $oExcel->Parse($ARGV[0]);
my($iR, $iC, $oWkS, $oWkC);
print STDERR "FILE :", $oBook->{File} , "\n";
print STDERR "COUNT :", $oBook->{SheetCount} , "\n";
print STDERR "AUTHOR:", $oBook->{Author} , "\n"
if defined $oBook->{Author};
for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++)
{
$oWkS = $oBook->{Worksheet}[$iSheet];
# skip this sheet if it's not what we're after
next if($oWkS->{Name} ne "AllWarpedImageNotes") ;
# note the sheet name to stderr
print STDERR "--------- SHEET:", $oWkS->{Name}, "\n";
for(my $iR = $oWkS->{MinRow} ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++)
{
for(my $iC = $oWkS->{MinCol} ;
defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ;
$iC++)
{
$oWkC = $oWkS->{Cells}[$iR][$iC];
#print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC);
if($oWkC) {
# this cell contains something
print '"',$oWkC->Value,'"';
} else {
# empty cell
print '""';
}
if ($iC < $oWkS->{MaxCol}) {
print "\t";
}
}
print "\n";
}
}