NAME
Spreadsheet::Reader::ExcelXML::CellToColumnRow - Translate Excel cell IDs to column row
SYNOPSIS
#!/usr/bin/env perl
package MyPackage;
use Moose;
with 'Spreadsheet::Reader::ExcelXML::CellToColumnRow';
sub set_error{} # Required method of this role
sub error{ print "Missing the column or row\n" } # Required method of this role
sub counting_from_zero{ 0 } # 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;
print '(' . join( ', ', $parser->my_method( 'B2' ) ) . ")'\n";
###########################
# SYNOPSIS Screen Output
# 01: (2, 2)
###########################
DESCRIPTION
This documentation is written to explain ways to use this module when writing your own excel parser. To use the general package for excel parsing out of the box please review the documentation for Workbooks, Worksheets, and Cells
This is a Moose Role. The role provides methods to convert back and forth betwee Excel Cell ID and ($column $row) lists. This role also provides a layer of abstraction so that it is possible to implement around modifiers 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 module counts from 1 (the excel convention) without implementation of around modifiers. Meaning that cell ID 'A1' is equal to (1, 1) and column row (3, 2) is equal to the cell ID 'C2'.
Requires
These are the methods required by this role and their default provider. All methods are imported straight across with no re-naming.
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 column and row integers. This method uses a count from 1 methodology. Since this method is actually just a layer of abstraction above the real method '_parse_column_row' 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 )
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 )
Accepts: ($column, $row) in that order
Returns: ( $excel_cell_id ) qr/[A-Z]{1,3}\d+/
get_excel_position( $integer )
Definition: This will process a position integer and check the method counting_from_zero to see whether to pass the value through straight accross or decrement it by 1. If the end user is using count from zero 'on' then the value is increased to arrive in the excel paradigm. (always counts from 1)
Accepts: an integer
Returns: an integer
get_used_position( $integer )
Definition: This will process a position integer and check the method counting_from_zero to see whether to pass the value through straight accross or decrease it by 1. If the end user is using count from zero 'on' then the value is decreased to arrived in the end users paradigm.
Accepts: an integer
Returns: an integer
SUPPORT
TODO
1. Nothing yet
AUTHOR
Jed Lund
jandrew@cpan.org
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) 2016 by Jed Lund
DEPENDENCIES
Spreadsheet::Reader::ExcelXML - the package
SEE ALSO
Spreadsheet::Read - generic Spreadsheet reader
Spreadsheet::ParseExcel - Excel binary version 2003 and earlier (.xls files)
Spreadsheet::XLSX - Excel version 2007 and later
Spreadsheet::ParseXLSX - Excel version 2007 and later
All lines in this package that use Log::Shiras are commented out