NAME

Spreadsheet::XLSX::Reader::LibXML::CellToRowColumn - Translate Excel cell IDs to row column

DESCRIPTION

This is a fairly simple implementation of a regex and math to find the column and row position in excel from an 'A1' style Excel cell ID. 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 of this module, however, is to count from zero. Meaning that cell A1 is equal to (0, 0). See the Attributes and Methods section for ways to change this behaviour.

SYNOPSIS

#!perl
package MyPackage;
use Moose;
with 'Spreadsheet::XLSX::Reader::LibXML::CellToColumnRow';

sub set_error{}
sub get_log_space{}
	
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)
###########################

Attributes

Attiributes are ways to change the instances behaviour and can be set as arguments to ->new

count_from_zero

    Definition: A boolean attribute that determines if the numerical output of parse_column_row provides a response counting from Zero or One. True = count from Zero.

    Accepts: $bool = (1|0)

Methods

Methods are object methods (not functional methods)

parse_column_row( $excel_row_id, $count_from_one )

    Definition: This is the way to turn an alpha numeric Excel cell ID into row and column integers. If count_from_zero = 1 but you want (column, row) pairs returned counting from 1 then set $count_from_one = 1. Or leave it blank to have the pair returned in the format defined by count_from_zero

    Accepts: $excel_row_id, $count_from_one

    Returns: ( $column_number, $row_number ) - integers

build_cell_label( $column, $row, $count_from_one )

    Definition: This is the way to turn a (column, row) pair into an excel ID. If $count_from_one is set then the ($column, $row pair will be treated at counting from one independant of how count_from_zero is set. integers

    Accepts: $column, $row, $count_from_one (in that order and position)

    Returns: ( $excel_cell_id ) - integers

counting_from_zero( $bool )

    Definition: This turns on (or off) counting from zero where the alternative is to count from 1.

    Accepts: $bool = (1|0)

    Returns: nothing

get_excel_position( $int )

    Definition: If you wish to use this sheet agnostically of the count_from_zero setting then you can use this method to translate integers to a count-from-one number. No action is taken if the attribute is set to 0.

    Accepts: a $count_from_one or a $count_from_zero int

    Returns: a $count_from_one int

get_used_position( $int )

    Definition: If you wish to use this sheet agnostically of the count_from_zero setting then you can use this method to translate integers from a count-from-one number to whatever scheme is in force from the attribute. No action is taken if the attribute is set to 0.

    Accepts: a $count_from_one int

    Returns: a $count_from_one or a $count_from_zero int

SUPPORT

TODO

    1. Add a read raw text between tags step in there somewhere

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) 2014 by Jed Lund

DEPENDENCIES

SEE ALSO