ParseExcel/Cell.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 88.8% 8 / 9 totaltotal 94.0% 63 / 67 CC 5 SCAR 6.5
CC
5
Cov
93%
encoding
4.2
get_hyperlink
2.0
BEGIN
1.0
CRAP 1.9
« ParseExcel/SaveParser/Worksheet.pm ↑ Summary ParseExcel/Workbook.pm »
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 21 our $VERSION = '0.66';
23  
24 ###############################################################################
25 #
26 # new()
27 #
28 # Constructor.
29 #
30 1122 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
31 1122 my ( $package, %properties ) = @_;
32 1122 my $self = \%properties;
33  
34 1122 bless $self, $package;
35 }
36  
37 ###############################################################################
38 #
39 # value()
40 #
41 # Returns the formatted value of the cell.
42 #
43 317 ▶sub value {
Subroutine value: called CC=1 SCAR=0.0
Pod documented
44  
45 317 my $self = shift;
46  
47 317 return $self->{_Value};
48 }
49  
50 ###############################################################################
51 #
52 # unformatted()
53 #
54 # Returns the unformatted value of the cell.
55 #
56 1 ▶sub unformatted {
Subroutine unformatted: called CC=1 SCAR=0.0
Pod documented
57  
58 1 my $self = shift;
59  
60 1 return $self->{Val};
61 }
62  
63 ###############################################################################
64 #
65 # get_format()
66 #
67 # Returns the Format object for the cell.
68 #
69 1 ▶sub get_format {
Subroutine get_format: called CC=1 SCAR=0.0
Pod documented
70  
71 1 my $self = shift;
72  
73 1 return $self->{Format};
74 }
75  
76 ###############################################################################
77 #
78 # type()
79 #
80 # Returns the type of cell such as Text, Numeric or Date.
81 #
82 3 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod documented
83  
84 3 my $self = shift;
85  
86 3 return $self->{Type};
87 }
88  
89 ###############################################################################
90 #
91 # encoding()
92 #
93 # Returns the character encoding of the cell.
94 #
95 3 ▶sub encoding {
Subroutine encoding: called CC=4 SCAR=14.3
Pod documented
96  
97 3 my $self = shift;
98  
99 3 ▶ if ( !defined $self->{Code} ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $self->{'Code'}) { } 1 2 3
elsif ($self->{'Code'} eq 'ucs2') { } 1 1 2
elsif ($self->{'Code'} eq '_native_') { } 1 0 1
100 1 return 1;
101 }
102 elsif ( $self->{Code} eq 'ucs2' ) {
103 1 return 2;
104 }
105 elsif ( $self->{Code} eq '_native_' ) {
106 1 return 3;
107 }
108 else {
109 0 return 0;
110 }
111  
112 0 return $self->{Code};
113 }
114  
115 ###############################################################################
116 #
117 # is_merged()
118 #
119 # Returns true if the cell is merged.
120 #
121 4 ▶sub is_merged {
Subroutine is_merged: called CC=1 SCAR=0.0
Pod documented
122  
123 4 my $self = shift;
124  
125 4 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 1 ▶sub get_rich_text {
Subroutine get_rich_text: called CC=1 SCAR=0.0
Pod documented
136  
137 1 my $self = shift;
138  
139 1 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 15 ▶sub get_hyperlink {
Subroutine get_hyperlink: called CC=2 SCAR=6.9
Pod documented
157 15 my $self = shift;
158  
159 15 ▶ return $self->{Hyperlink} if exists $self->{Hyperlink};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"Hyperlink"} 14 1 15
160 1 return undef;
161 }
162  
163 #
164 ###############################################################################
165 #
166 # Mapping between legacy method names and new names.
167 #
168 {
169 21 ▶ no warnings; # Ignore warnings about variables used only once.
Subroutine BEGIN: called CC=1 SCAR=0.0
170 21 *Value = \&value;
171 }
172  
173 21 1;
174  
175 __END__
« ParseExcel/SaveParser/Worksheet.pm ↑ Summary ParseExcel/Workbook.pm »