NAME

Spreadsheet::Reader::ExcelXML::XMLReader::PositionSharedStrings - Position based sharedStrings Reader

SYNOPSIS

#!/usr/bin/env perl
use Data::Dumper;
use MooseX::ShortCut::BuildInstance qw( build_instance );
use Spreadsheet::Reader::ExcelXML::XMLReader;
use Spreadsheet::Reader::ExcelXML::XMLReader::PositionSharedStrings;
use	Spreadsheet::Reader::ExcelXML::SharedStrings;

my $file_instance = build_instance(
    package => 'SharedStringsInstance',
	workbook_inst => Spreadsheet::Reader::ExcelXML::Workbook->new,
	superclasses =>[
		'Spreadsheet::Reader::ExcelXML::XMLReader'
	],
	add_roles_in_sequence =>[
		'Spreadsheet::Reader::ExcelXML::XMLReader::PositionSharedStrings',
		'Spreadsheet::Reader::ExcelXML::SharedStrings',
	],
);

DESCRIPTION

This documentation is written to explain ways to use this module when writing your own excel parser or extending this package. To use the general package for excel parsing out of the box please review the documentation for Workbooks , Worksheets , and Cells.

This role is written to extend Spreadsheet::Reader::ExcelXML::XMLReader. It adds functionality to read position based sharedStrings files. It presents this functionality in compliance with the top level interface . This POD only describes the functionality incrementally provided by this module. For an overview of sharedStrings.xml reading see Spreadsheet::Reader::ExcelXML::SharedStrings

Requires

These are the methods required by this role and their default provider. All methods are imported straight across with no re-naming.

Methods

These are the primary ways to use this class. For additional SharedStrings options see the Attributes section.

get_shared_string( $positive_int )

    Definition: This returns the data in the shared strings file identified by the $positive_int position for position in position based sharedStrings files.

    Accepts: $positive_int ( a positive integer )

    Returns: a hash ref with the key 'raw_text' and all coallated text for that xml node as the value. If there is associated rich text in the node and "group_return_type" in Spreadsheet::Reader::ExcelXML is set to 'instance' then it will also have a 'rich_text' key with the value set as an arrayref of pairs (not sub array refs) with the first value being the position of the raw_text from zero that the formatting is applied and the second position as the settings for that format. Ex.

    {
    	raw_text => 'Hello World',
    	rich_text =>[
    		2,# Starting with the letter 'l' apply the format
    		{
    			'color' => {
    				'rgb' => 'FFFF0000'
    			},
    			'sz' => '11',
    			'b' => undef,
    			'scheme' => 'minor',
    			'rFont' => 'Calibri',
    			'family' => '2'
    		},
    		6,# Starting with the letter 'W' apply the format
    		{
    			'color' => {
    				'rgb' => 'FF0070C0'
    			},
    			'sz' => '20',
    			'b' => undef,
    			'scheme' => 'minor',
    			'rFont' => 'Calibri',
    			'family' => '2'
    		}
    	]
    }

load_unique_bits

    Definition: When the xml file first loads this is available to pull customized data. It mostly pulls metadata and stores it in hidden attributes for use later. If all goes according to plan it sets "good_load" in Spreadsheet::Reader::ExcelXML::XMLReader to 1.

    Accepts: Nothing

    Returns: Nothing

Attributes

Data passed to new when creating an instance of this class. For modification of this(ese) attribute(s) see the listed 'attribute methods'. For more information on attributes see Moose::Manual::Attributes. The easiest way to modify this(ese) attribute(s) is when a classinstance is created and before it is passed to the workbook or parser.

cache_positions

    Definition: Especially for sheets with lots of stored text the parser can slow way down when accessing each postion. This is because the text is not always stored sequentially and the reader is a JIT linear parser. To go back it must restart and index through each position till it gets to the right place. This is especially true for excel sheets that have experienced any significant level of manual intervention prior to being read. This attribute turns (default) on caching for shared strings so the parser only has to read through the shared strings once. When the read is complete all the way to the end it will also release the shared strings file in order to free up some space. (a small win in exchange for the space taken by the cache). The trade off here is that all intermediate shared strings are fully read before reading the target string. This means early reads will be slower. For sheets that only have numbers stored or at least have very few strings this will likely not be a initial hit (or speed improvement). In order to minimize the physical size of the cache, if there is only a text string stored in the shared strings position then only the string will be stored (not as a value to a raw_text hash key). It will then reconstitue into a hashref when requested.

    Default: 1 = caching is on

    Range: 1|0

    Attribute required: yes

    attribute methods Methods provided to adjust this attribute

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

SEE ALSO