| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Spreadsheet::ParseExcel::Workbook; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Spreadsheet::ParseExcel::Workbook - A class for Workbooks. |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Used in conjunction with Spreadsheet::ParseExcel. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Copyright (c) 2014 Douglas Wilson |
|
10
|
|
|
|
|
|
|
# Copyright (c) 2009-2013 John McNamara |
|
11
|
|
|
|
|
|
|
# Copyright (c) 2006-2008 Gabor Szabo |
|
12
|
|
|
|
|
|
|
# Copyright (c) 2000-2006 Kawai Takanori |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# perltidy with standard settings. |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
# Documentation after __END__ |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
|
|
19
|
21
|
|
|
21
|
|
116
|
use strict; |
|
|
21
|
|
|
|
|
40
|
|
|
|
21
|
|
|
|
|
775
|
|
|
20
|
21
|
|
|
21
|
|
113
|
use warnings; |
|
|
21
|
|
|
|
|
39
|
|
|
|
21
|
|
|
|
|
13301
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.65'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
############################################################################### |
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
# new() |
|
27
|
|
|
|
|
|
|
# |
|
28
|
|
|
|
|
|
|
# Constructor. |
|
29
|
|
|
|
|
|
|
# |
|
30
|
|
|
|
|
|
|
sub new { |
|
31
|
48
|
|
|
48
|
0
|
125
|
my ($class) = @_; |
|
32
|
48
|
|
|
|
|
120
|
my $self = {}; |
|
33
|
48
|
|
|
|
|
390
|
bless $self, $class; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
############################################################################### |
|
37
|
|
|
|
|
|
|
sub color_idx_to_rgb { |
|
38
|
1
|
|
|
1
|
0
|
2
|
my( $workbook, $iidx ) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
2
|
my $palette = $workbook->{aColor}; |
|
41
|
1
|
50
|
|
|
|
7
|
return ( ( defined $palette->[$iidx] ) ? $palette->[$iidx] : $palette->[0] ); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
############################################################################### |
|
45
|
|
|
|
|
|
|
# |
|
46
|
|
|
|
|
|
|
# worksheet() |
|
47
|
|
|
|
|
|
|
# |
|
48
|
|
|
|
|
|
|
# This method returns a single Worksheet object using either its name or index. |
|
49
|
|
|
|
|
|
|
# |
|
50
|
|
|
|
|
|
|
sub worksheet { |
|
51
|
118
|
|
|
118
|
1
|
93636
|
my ( $oBook, $sName ) = @_; |
|
52
|
118
|
|
|
|
|
171
|
my $oWkS; |
|
53
|
118
|
|
|
|
|
162
|
foreach $oWkS ( @{ $oBook->{Worksheet} } ) { |
|
|
118
|
|
|
|
|
501
|
|
|
54
|
213
|
100
|
|
|
|
921
|
return $oWkS if ( $oWkS->{Name} eq $sName ); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
37
|
50
|
|
|
|
310
|
if ( $sName =~ /^\d+$/ ) { |
|
57
|
37
|
|
|
|
|
146
|
return $oBook->{Worksheet}->[$sName]; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
0
|
|
|
|
|
0
|
return undef; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
############################################################################### |
|
63
|
|
|
|
|
|
|
# |
|
64
|
|
|
|
|
|
|
# worksheets() |
|
65
|
|
|
|
|
|
|
# |
|
66
|
|
|
|
|
|
|
# Returns an array of Worksheet objects. |
|
67
|
|
|
|
|
|
|
# |
|
68
|
|
|
|
|
|
|
sub worksheets { |
|
69
|
1
|
|
|
1
|
1
|
12
|
my $self = shift; |
|
70
|
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
3
|
return @{ $self->{Worksheet} }; |
|
|
1
|
|
|
|
|
6
|
|
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
############################################################################### |
|
75
|
|
|
|
|
|
|
# |
|
76
|
|
|
|
|
|
|
# worksheet_count() |
|
77
|
|
|
|
|
|
|
# |
|
78
|
|
|
|
|
|
|
# Returns the number Woksheet objects in the Workbook. |
|
79
|
|
|
|
|
|
|
# |
|
80
|
|
|
|
|
|
|
sub worksheet_count { |
|
81
|
|
|
|
|
|
|
|
|
82
|
1
|
|
|
1
|
1
|
778
|
my $self = shift; |
|
83
|
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
37
|
return $self->{SheetCount}; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
############################################################################### |
|
88
|
|
|
|
|
|
|
# |
|
89
|
|
|
|
|
|
|
# get_filename() |
|
90
|
|
|
|
|
|
|
# |
|
91
|
|
|
|
|
|
|
# Returns the name of the Excel file of C if the data was read from a filehandle rather than a file. |
|
92
|
|
|
|
|
|
|
# |
|
93
|
|
|
|
|
|
|
sub get_filename { |
|
94
|
|
|
|
|
|
|
|
|
95
|
2
|
|
|
2
|
1
|
1613
|
my $self = shift; |
|
96
|
|
|
|
|
|
|
|
|
97
|
2
|
|
|
|
|
8
|
return $self->{File}; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
############################################################################### |
|
101
|
|
|
|
|
|
|
# |
|
102
|
|
|
|
|
|
|
# get_print_areas() |
|
103
|
|
|
|
|
|
|
# |
|
104
|
|
|
|
|
|
|
# Returns an array ref of print areas. |
|
105
|
|
|
|
|
|
|
# |
|
106
|
|
|
|
|
|
|
# TODO. This should really be a Worksheet method. |
|
107
|
|
|
|
|
|
|
# |
|
108
|
|
|
|
|
|
|
sub get_print_areas { |
|
109
|
|
|
|
|
|
|
|
|
110
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
|
111
|
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
3
|
return $self->{PrintArea}; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
############################################################################### |
|
116
|
|
|
|
|
|
|
# |
|
117
|
|
|
|
|
|
|
# get_print_titles() |
|
118
|
|
|
|
|
|
|
# |
|
119
|
|
|
|
|
|
|
# Returns an array ref of print title hash refs. |
|
120
|
|
|
|
|
|
|
# |
|
121
|
|
|
|
|
|
|
# TODO. This should really be a Worksheet method. |
|
122
|
|
|
|
|
|
|
# |
|
123
|
|
|
|
|
|
|
sub get_print_titles { |
|
124
|
|
|
|
|
|
|
|
|
125
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
|
126
|
|
|
|
|
|
|
|
|
127
|
1
|
|
|
|
|
5
|
return $self->{PrintTitle}; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
############################################################################### |
|
131
|
|
|
|
|
|
|
# |
|
132
|
|
|
|
|
|
|
# using_1904_date() |
|
133
|
|
|
|
|
|
|
# |
|
134
|
|
|
|
|
|
|
# Returns true if the Excel file is using the 1904 date epoch. |
|
135
|
|
|
|
|
|
|
# |
|
136
|
|
|
|
|
|
|
sub using_1904_date { |
|
137
|
|
|
|
|
|
|
|
|
138
|
2
|
|
|
2
|
1
|
2547
|
my $self = shift; |
|
139
|
|
|
|
|
|
|
|
|
140
|
2
|
|
|
|
|
11
|
return $self->{Flg1904}; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
############################################################################### |
|
144
|
|
|
|
|
|
|
# |
|
145
|
|
|
|
|
|
|
# ParseAbort() |
|
146
|
|
|
|
|
|
|
# |
|
147
|
|
|
|
|
|
|
# Todo |
|
148
|
|
|
|
|
|
|
# |
|
149
|
|
|
|
|
|
|
sub ParseAbort { |
|
150
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $val ) = @_; |
|
151
|
0
|
|
|
|
|
0
|
$self->{_ParseAbort} = $val; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 get_active_sheet() |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Return the number of the active (open) worksheet (at the time the workbook |
|
157
|
|
|
|
|
|
|
was saved. May return undef. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub get_active_sheet { |
|
162
|
2
|
|
|
2
|
1
|
18
|
my $workbook = shift; |
|
163
|
|
|
|
|
|
|
|
|
164
|
2
|
|
|
|
|
8
|
return $workbook->{ActiveSheet}; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
############################################################################### |
|
168
|
|
|
|
|
|
|
# |
|
169
|
|
|
|
|
|
|
# Parse(). Deprecated. |
|
170
|
|
|
|
|
|
|
# |
|
171
|
|
|
|
|
|
|
# Syntactic wrapper around Spreadsheet::ParseExcel::Parse(). |
|
172
|
|
|
|
|
|
|
# This method is *deprecated* since it doesn't conform to the current |
|
173
|
|
|
|
|
|
|
# error handling in the S::PE Parse() method. |
|
174
|
|
|
|
|
|
|
# |
|
175
|
|
|
|
|
|
|
sub Parse { |
|
176
|
|
|
|
|
|
|
|
|
177
|
9
|
|
|
9
|
0
|
940678
|
my ( $class, $source, $formatter ) = @_; |
|
178
|
9
|
|
|
|
|
71
|
my $excel = Spreadsheet::ParseExcel->new(); |
|
179
|
9
|
|
|
|
|
46
|
my $workbook = $excel->Parse( $source, $formatter ); |
|
180
|
9
|
|
|
|
|
27
|
$workbook->{_Excel} = $excel; |
|
181
|
9
|
|
|
|
|
47
|
return $workbook; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
############################################################################### |
|
185
|
|
|
|
|
|
|
# |
|
186
|
|
|
|
|
|
|
# Mapping between legacy method names and new names. |
|
187
|
|
|
|
|
|
|
# |
|
188
|
|
|
|
|
|
|
{ |
|
189
|
21
|
|
|
21
|
|
146
|
no warnings; # Ignore warnings about variables used only once. |
|
|
21
|
|
|
|
|
45
|
|
|
|
21
|
|
|
|
|
1470
|
|
|
190
|
|
|
|
|
|
|
*Worksheet = *worksheet; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
1; |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
__END__ |