File Coverage

blib/lib/Spreadsheet/ParseExcel/Cell.pm
Criterion Covered Total %
statement 32 34 94.1
branch 7 8 87.5
condition n/a
subroutine 12 12 100.0
pod 8 9 88.8
total 59 63 93.6


line stmt bran cond sub pod time code
1             package Spreadsheet::ParseExcel::Cell;
2              
3             ###############################################################################
4             #
5             # Spreadsheet::ParseExcel::Cell - A class for Cell data and formatting.
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   105 use strict;
  21         34  
  21         779  
20 21     21   374 use warnings;
  21         41  
  21         8427  
21              
22             our $VERSION = '0.65';
23              
24             ###############################################################################
25             #
26             # new()
27             #
28             # Constructor.
29             #
30             sub new {
31 1122     1122 0 5268 my ( $package, %properties ) = @_;
32 1122         1578 my $self = \%properties;
33              
34 1122         4955 bless $self, $package;
35             }
36              
37             ###############################################################################
38             #
39             # value()
40             #
41             # Returns the formatted value of the cell.
42             #
43             sub value {
44              
45 317     317 1 65572 my $self = shift;
46              
47 317         1832 return $self->{_Value};
48             }
49              
50             ###############################################################################
51             #
52             # unformatted()
53             #
54             # Returns the unformatted value of the cell.
55             #
56             sub unformatted {
57              
58 1     1 1 9 my $self = shift;
59              
60 1         5 return $self->{Val};
61             }
62              
63             ###############################################################################
64             #
65             # get_format()
66             #
67             # Returns the Format object for the cell.
68             #
69             sub get_format {
70              
71 1     1 1 7 my $self = shift;
72              
73 1         5 return $self->{Format};
74             }
75              
76             ###############################################################################
77             #
78             # type()
79             #
80             # Returns the type of cell such as Text, Numeric or Date.
81             #
82             sub type {
83              
84 3     3 1 17 my $self = shift;
85              
86 3         11 return $self->{Type};
87             }
88              
89             ###############################################################################
90             #
91             # encoding()
92             #
93             # Returns the character encoding of the cell.
94             #
95             sub encoding {
96              
97 3     3 1 31 my $self = shift;
98              
99 3 100       23 if ( !defined $self->{Code} ) {
    100          
    50          
100 1         4 return 1;
101             }
102             elsif ( $self->{Code} eq 'ucs2' ) {
103 1         3 return 2;
104             }
105             elsif ( $self->{Code} eq '_native_' ) {
106 1         4 return 3;
107             }
108             else {
109 0         0 return 0;
110             }
111              
112 0         0 return $self->{Code};
113             }
114              
115             ###############################################################################
116             #
117             # is_merged()
118             #
119             # Returns true if the cell is merged.
120             #
121             sub is_merged {
122              
123 4     4 1 27 my $self = shift;
124              
125 4         12 return $self->{Merged};
126             }
127              
128             ###############################################################################
129             #
130             # get_rich_text()
131             #
132             # Returns an array ref of font information about each string block in a "rich",
133             # i.e. multi-format, string.
134             #
135             sub get_rich_text {
136              
137 1     1 1 11 my $self = shift;
138              
139 1         3 return $self->{Rich};
140             }
141              
142             ###############################################################################
143             #
144             # get_hyperlink {
145             #
146             # Returns an array ref of hyperlink information if the cell contains a hyperlink.
147             # Returns undef otherwise
148             #
149             # [0] : Description of link (You may want $cell->value, as it will have rich text)
150             # [1] : URL - the link expressed as a URL. N.B. relative URLs will be defaulted to
151             # the directory of the input file, if the input file name is known. Otherwise
152             # %REL% will be inserted as a place-holder. Depending on your application,
153             # you should either remove %REL% or replace it with the appropriate path.
154             # [2] : Target frame (or undef if none)
155              
156             sub get_hyperlink {
157 15     15 1 4379 my $self = shift;
158              
159 15 100       67 return $self->{Hyperlink} if exists $self->{Hyperlink};
160 1         3 return undef;
161             }
162              
163             #
164             ###############################################################################
165             #
166             # Mapping between legacy method names and new names.
167             #
168             {
169 21     21   135 no warnings; # Ignore warnings about variables used only once.
  21         42  
  21         1423  
170             *Value = \&value;
171             }
172              
173             1;
174              
175             __END__