File: dmpEx_2xml.pl

package info (click to toggle)
libspreadsheet-parseexcel-perl 0.6500-1.1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,852 kB
  • sloc: perl: 9,442; makefile: 12
file content (44 lines) | stat: -rwxr-xr-x 1,446 bytes parent folder | download | duplicates (6)
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
#Khalid EZZARAOUI khalid@yromem.com
use strict;
if(!(defined $ARGV[0])) {
    print<<EOF;
Usage: $0 Excel_File
EOF
    exit;
}
use Spreadsheet::ParseExcel;
my $oExcel = new Spreadsheet::ParseExcel;
my $oBook = $oExcel->Parse($ARGV[0]);

my($iR, $iC, $oWkS, $oWkC);
print '<?xml version="1.0" encoding="ISO-8859-1"?>', "\n";
print "<document>", "\n";

print "\t", "<meta>", "\n";
print "\t\t", "<file>", $oBook->{File} , "</file>", "\n";
print "\t\t", "<sheetcount>", $oBook->{SheetCount} , "</sheetcount>", "\n";
print "\t\t", "<author>", $oBook->{Author} , "</author>", "\n";
print "\t", "</meta>", "\n";

print "\t", "<sheets>", "\n";
#for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++) {
#    $oWkS = $oBook->{Worksheet}[$iSheet];
foreach my $oWkS (@{$oBook->{Worksheet}}) {
	print "\t\t", "<sheet " ;
	print "name=\"", $oWkS->{Name}, "\" >",  "\n";
	for(my $iR = $oWkS->{MinRow} ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) {
		print "\t\t\t", "<row num=\"", $iR, "\">", "\n" ;
		for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) {
			$oWkC = $oWkS->{Cells}[$iR][$iC];
			print "\t\t\t\t", "<col num=\"", $iC, "\"", ">", $oWkC->Value, "</col>", "\n" if($oWkC);
			# print $oWkC->{_Kind}, "\n";
			}
		print "\t\t\t", "</row>", "\n" ;
	}
	print "\t\t", "</sheet>\n" ;
}
	
print "\t", "</sheets>", "\n";

print "</document>", "\n";