NAME
Spreadsheet::XLSX::Reader::LibXML::CellToRowColumn - Translate Excel cell IDs to row column
SYNOPSIS
#!perl
package MyPackage;
use Moose;
with 'Spreadsheet::XLSX::Reader::LibXML::CellToColumnRow';
sub set_error{} #Required method of this role
sub get_log_space{} #Required method of this role
sub my_method{
my ( $self, $cell ) = @_;
my ($column, $row ) = $self->parse_column_row( $cell );
print $self->error if( !defined $column or !defined $row );
return ($column, $row );
}
package main;
my $parser = MyPackage->new( count_from_zero => 0 );
print '(' . join( ', ', $parser->my_method( 'B2' ) ) . ")'\n";
###########################
# SYNOPSIS Screen Output
# 01: (2, 2)
###########################
DESCRIPTION
This is a Moose Role. The role provides methods to convert back and forth betwee Excel Cell ID and row column numbers. The role also provides a layer of abstraction so that it is possible to implement around on these methods so that the data provided by the user can be in the user context and the method implementation will still be in the Excel context. For example this package uses this abstraction to allow the user to call or receive row column numbers in either the count from zero context used by Spreadsheet::ParseExcel or the count from one context used by Excel. It is important to note that column letters do not equal digits in a modern 26 position numeral system since the excel implementation is effectivly zeroless.
The default for this module is to count from 1 (the excel convention). Meaning that cell ID 'A1' is equal to (1, 1) and column row (3, 2) is equal to the cell ID 'C2'.
Methods
Methods are object methods (not functional methods)
parse_column_row( $excel_cell_id )
Definition: This is the way to turn an alpha numeric Excel cell ID into row and column integers. This method uses a count from 1 methodology. Since this method is actually just a layer of abstraction above the real method for the calculation you can wrap it in an around block to modify the output to the desired user format without affecting other parts of the package that need the unfiltered conversion. If you want both then use the following call when unfiltered results are required;
$self->_parse_column_row( $excel_cell_id )
Accepts: $excel_cell_id
Returns: ( $column_number, $row_number ) - integers
build_cell_label( $column, $row, )
Definition: This is the way to turn a (column, row) pair into an Excel Cell ID. The underlying method uses a count from 1 methodology. Since this method is actually just a layer of abstraction above the real method for the calculation you can wrap it in an around block to modify the input from the implemented user format to the count from one methodology without affecting other parts of the package that need the unfiltered conversion. If you want both then use the following call when unfiltered results are required;
$self->_build_cell_label( $column, $row )
The column and the row must be provided in that order for both public and private methods.
Accepts: $column, $row, $count_from_one (in that order and position)
Returns: ( $excel_cell_id ) - qr/[A-Z]{1,3}\d+/
SUPPORT
TODO
1. Nothing yet
AUTHOR
COPYRIGHT
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
This software is copyrighted (c) 2014 by Jed Lund
DEPENDENCIES
SEE ALSO
Spreadsheet::ParseExcel - Excel 2003 and earlier
Spreadsheet::XLSX - 2007+
Spreadsheet::ParseXLSX - 2007+
All lines in this package that use Log::Shiras are commented out