The following Cell methods are available:
$cell->value()
$cell->unformatted()
$cell->get_format()
$cell->type()
$cell->encoding()
$cell->is_merged()
$cell->get_rich_text()
$cell->get_hyperlink()
value()
The "value()" method returns the formatted value of the cell.
my $value = $cell->value();
Formatted in this sense refers to the numeric format of the cell value. For example a number such as
40177 might be formatted as 40,117, 40117.000 or even as the date 2009/12/30.
If the cell doesn't contain a numeric format then the formatted and unformatted cell values are the same,
see the "unformatted()" method below.
For a defined $cell the "value()" method will always return a value.
In the case of a cell with formatting but no numeric or string contents the method will return the empty
string ''.
unformatted()
The "unformatted()" method returns the unformatted value of the cell.
my $unformatted = $cell->unformatted();
Returns the cell value without a numeric format. See the "value()" method above.
get_format()
The "get_format()" method returns the Spreadsheet::ParseExcel::Format object for the cell.
my $format = $cell->get_format();
If a user defined format hasn't been applied to the cell then the default cell format is returned.
type()
The "type()" method returns the type of cell such as Text, Numeric or Date. If the type was detected as
Numeric, and the Cell Format matches "m{^[dmy][-\\/dmy]*$}i", it will be treated as a Date type.
my $type = $cell->type();
See also "Dates and Time in Excel".
encoding()
The "encoding()" method returns the character encoding of the cell.
my $encoding = $cell->encoding();
This method is only of interest to developers. In general Spreadsheet::ParseExcel will return all
character strings in UTF-8 regardless of the encoding used by Excel.
The "encoding()" method returns one of the following values:
• 0: Unknown format. This shouldn't happen. In the default case the format should be 1.
• 1: 8bit ASCII or single byte UTF-16. This indicates that the characters are encoded in a single byte.
In Excel 95 and earlier This usually meant ASCII or an international variant. In Excel 97 it refers
to a compressed UTF-16 character string where all of the high order bytes are 0 and are omitted to
save space.
• 2: UTF-16BE.
• 3: Native encoding. In Excel 95 and earlier this encoding was used to represent multi-byte character
encodings such as SJIS.
is_merged()
The "is_merged()" method returns true if the cell is merged.
my $is_merged = $cell->is_merged();
Returns "undef" if the property isn't set.
get_rich_text()
The "get_rich_text()" method returns an array ref of font information about each string block in a
"rich", i.e. multi-format, string.
my $rich_text = $cell->get_rich_text();
The return value is an arrayref of arrayrefs in the form:
[
[ $start_position, $font_object ],
...,
]
Returns undef if the property isn't set.
get_hyperlink()
If a cell contains a hyperlink, the "get_hyperlink()" method returns an array ref of information about
it.
A cell can contain at most one hyperlink. If it does, it contains no other value.
Otherwise, it returns undef;
The array contains:
• 0: Description (what's displayed); undef if not present
• 1: Link, converted to an appropriate URL - Note: Relative links are based on the input file. %REL%
is used if the input file is unknown (e.g. a file handle or scalar)
• 2: Target - target frame (or undef if none)