NAME

Spreadsheet::XLSX::Reader::LibXML::XMLReader::Styles - A LibXML::Reader styles base class

SYNOPSIS

	#!/usr/bin/env perl
	$|=1;
	use Data::Dumper;
	use MooseX::ShortCut::BuildInstance qw( build_instance );
	use Spreadsheet::XLSX::Reader::LibXML::Error;
	use Spreadsheet::XLSX::Reader::LibXML::XMLReader::Styles;

	my $file_instance = build_instance(
	    package      => 'StylesInstance',
	    superclasses => ['Spreadsheet::XLSX::Reader::LibXML::XMLReader::Styles'],
	    file         => 'styles.xml',
	    error_inst   => Spreadsheet::XLSX::Reader::LibXML::Error->new,
	    add_roles_in_sequence => [qw(
	        Spreadsheet::XLSX::Reader::LibXML::FmtDefault
	        Spreadsheet::XLSX::Reader::LibXML::ParseExcelFormatStrings
	    )],
	);
	print Dumper( $file_instance->get_format_position( 2 ) );

	#######################################
	# SYNOPSIS Screen Output
	# 01: $VAR1 = {
	# 02:    'applyNumberFormat' => '1',
	# 03:    'fontId' => '0',
	# 04:    'fonts'  => {
	# 05:       'color' => {
	# 06:          'theme' => '1'
	# 07:       },
	# 08:       'sz'     => '11',
	# 09:       'name'   => 'Calibri',
	# 10:       'scheme' => 'minor',
	# 11:       'family' => '2'
	# 12:    },
	# 13:    'numFmtId' => '164',
	# 14:    'fillId'   => '0',
	# 15:    'xfId'     => '0',
	# 16:    'borders' => {
	# 17:       'left'     => 1,
	# 18:       'right'    => 1,
	# 19:       'top'      => 1,
	# 20:       'diagonal' => 1,
	# 21:       'bottom'   => 1
	# 22:    },
	# 23:    'borderId' => '0',
	# 24:    'cellStyleXfs' => {
	# 25:       'fillId'   => '0',
	# 26:       'fontId'   => '0',
	# 27:       'borderId' => '0',
	# 28:       'numFmtId' => '0'
	# 29:    },
	# 30:    'fills' => {
	# 31:       'patternFill' => {
	# 32:          'patternType' => 'none'
	# 33:       }
	# 34:    },
	# 35:    'numFmts' => bless( {
	# 36:       'name' => 'Excel_date_164',
	# 37:       'uniq' => 86,
	# 38:       'coercion' => bless( { 
                    ~ 180 lines hidden ~
	# 219:      }, 'Type::Coercion' )
	# 220:    }, 'Type::Tiny' )
	# 221: };
	#######################################

DESCRIPTION

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

This class is written to get useful data from the sub file 'styles.xml' that is a member of a zipped (.xlsx) archive or a stand alone XML text file of the same format. The styles.xml file contains the format and display options used by Excel for showing the stored data. To unzip an Excel file manually change the \.xlsx extention to \.zip and windows should do (most) of the rest. For linux use an unzip utility. ( Archive::Zip for instance :)

This documentation is the explanation of this specific module. For a general explanation of the class and how to to add or adjust its place in the larger package see the Styles POD.

This module is the simplified way to extract information from the styles file needed when doing high level reading of an Excel spread sheet. In order to do so it subclasses the module Spreadsheet::XLSX::Reader::LibXML::XMLReader and leverages one hard coded role Spreadsheet::XLSX::Reader::LibXML::XMLReader::XMLToPerlData Additionally the module will error if not built with roles that supply two additional methods. The methods are get_defined_excel_format and parse_excel_format_string . The links lead to the default source of these methods in the package. These methods are intentionally not hard coded to this class so that the user can change them at run time. See the attributes "default_format_list" in Spreadsheet::XLSX::Reader::LibXML and "format_string_parser" in Spreadsheet::XLSX::Reader::LibXML for more explanation. Read about the function of each when replacing them. If you want to use the roles as-is, one way to integrate them is with MooseX::ShortCut::BuildInstance. The 'on-the-fly' roles also add other methods (not documented here) to this class. Look at the documentation for those modules to see what else comes with them.

Method(s)

These are the methods just provided by this class. Look at the documentation for the the two modules consumed by this class for their elements. Spreadsheet::XLSX::Reader::LibXML::XMLReader and Spreadsheet::XLSX::Reader::LibXML::XMLReader::XMLToPerlData

get_format_position( $position, [$header] )

    Definition: This will return the styles information from the identified $position (Counting from zero). the target position is usually drawn from the cell data stored in the worksheet. The information is returned as a perl hash ref. Since the styles data is in two tiers it finds all the subtier information for each indicated piece and appends them to the hash ref as values for each type key. If you only want a specific branch then you can add the branch $header key and the returned value will only contain that leg. If you know the second level position for that header then call get_sub_format_position as a quicker substitute.

    Accepts: $position = an integer for the styles $position. (required)

    Accepts: $header = the target header key (optional)

    Returns: a hash ref of data

get_sub_format_position( $position, $header )

    Definition: This will return the styles information from the identified $position (Counting from zero) for the specific $header. The information is returned as a perl hash ref. This call will not seek a second level just return the data from that header.

    Accepts: $position = an integer for the styles $position (required)

    Accepts: $header = a string for the header key (required)

    Returns: a hash ref of data

get_default_format_position( $position, $header )

    Definition: For any cell that does not have a unquely identified format excel generally stores a default format for the remainder of the sheet. This will return the two tiered default styles information. If you only want the default from a specific header then add the $header string to the method call. The information is returned as a perl hash ref.

    Accepts: $header = a string for the header key (optional)

    Returns: a hash ref of data

SUPPORT

TODO

    2. This was one of the first XMLReader parsers I wrote and the XML parsing is crufty (needs a scrub)

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