1use XML::SAXDriver::Excel;
2
3my $code_handler= new code_handler;
4
5our $DATA = <<"CSV";
6field1, field2, field3
7F1_1, F1_2, F1_3
8F2_1, F2_2, F2_3
9F3_1,, F3_3
10,, F4_3
11,,
12F6_1
13F7_1,,
14,F8_2,
15CSV
16
17
18my $driver = XML::SAXDriver::Excel->new(Source => {SystemId => "Test.xls"},
19                                      Handler => $code_handler,
20                                      Dynamic_Col_Headings => 1,
21                                      IndentChar           => '  ',
22                                      File_Tag   => 'code');
23$driver->parse();
24
25
26package code_handler;
27
28sub new
29  { my $class= ref $_[0] || $_[0];
30    return bless {}, $class;
31  }
32
33sub start_document
34  { my $code_handler= shift;
35    my $document= shift;
36  }
37
38sub end_document
39  { my $code_handler= shift;
40    my $document= shift;
41  }
42
43sub start_element
44  { my $code_handler= shift;
45    my $element= shift;
46    my $name= $element->{Name};
47    my $atts= $element->{Attributes};
48    print "<$name";
49    foreach my $att (sort keys %$atts)
50      {print " $att='$atts->{$att}'";}
51    print ">";
52  }
53
54sub characters
55  { my $code_handler= shift;
56    my $character= shift;
57    print $character->{Data} if( defined $character->{Data});
58  }
59
60sub end_element
61  { my $code_handler= shift;
62    my $element= shift;
63    my $name= $element->{Name};
64    print "</$name>";
65  }
66
67