The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

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

        sub set_error{} #Required method of this role
        sub error{ print "Missing the column or row\n" }
                
        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 mofifiers 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 methods used by this role but not provided by the role. Any class consuming this role will not build unless it first provides these methods prior to loading this role.

set_error( $error_string )

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 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 )
            

    The column and the row must be provided in that order for both public and private methods.

    Accepts: ($column, $row) in that order

    Returns: ( $excel_cell_id ) qr/[A-Z]{1,3}\d+/

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

DEPENDENCIES

SEE ALSO