line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /mirror/perl/File-Extract/trunk/lib/File/Extract/Excel.pm 4210 2007-10-27T13:43:07.499967Z daisuke $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2005 Daisuke Maki |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package File::Extract::Excel; |
7
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
88
|
|
8
|
2
|
|
|
2
|
|
12
|
use base qw(File::Extract::Base); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1222
|
|
9
|
2
|
|
|
2
|
|
5095
|
use Spreadsheet::ParseExcel; |
|
2
|
|
|
|
|
187489
|
|
|
2
|
|
|
|
|
652
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
1
|
8
|
sub mime_type { 'application/excel' } |
12
|
|
|
|
|
|
|
sub extract |
13
|
|
|
|
|
|
|
{ |
14
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
15
|
0
|
|
|
|
|
|
my $file = shift; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $book = Spreadsheet::ParseExcel::Workbook->Parse($file); |
18
|
0
|
0
|
|
|
|
|
return unless $book; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $text = ''; |
21
|
0
|
|
|
|
|
|
foreach my $sheet (@{$book->{Worksheet}}) { |
|
0
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
last if !defined $sheet->{MaxRow}; |
23
|
0
|
|
|
|
|
|
foreach my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) { |
24
|
0
|
|
|
|
|
|
foreach my $col ($sheet->{MinCol} .. $sheet->{MaxCol}) { |
25
|
0
|
|
|
|
|
|
my $cell = $sheet->{Cells}[$row][$col]; |
26
|
0
|
0
|
|
|
|
|
if ($cell) { |
27
|
0
|
|
|
|
|
|
$text .= $cell->Value; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
$text .= " "; |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
|
$text .= "\n"; |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
|
|
|
$text .= "\n\n"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return File::Extract::Result->new( |
37
|
0
|
|
0
|
|
|
|
text => eval { $self->recode($text) } || $text, |
38
|
|
|
|
|
|
|
filename => $file, |
39
|
|
|
|
|
|
|
mime_type => $self->mime_type |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |