File Coverage

lib/Spreadsheet/Reader/ExcelXML/XMLReader/WorkbookXML.pm
Criterion Covered Total %
statement 14 15 93.3
branch 3 4 75.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 22 24 91.6


line stmt bran cond sub pod time code
1             package Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookXML;
2             our $AUTHORITY = 'cpan:JANDREW';
3 6     6   21823 use version; our $VERSION = version->declare('v0.16.8');
  6         11  
  6         44  
4             ###LogSD warn "You uncovered internal logging statements for Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookXML-$VERSION";
5              
6 6     6   679 use Moose::Role;
  6         12  
  6         46  
7             requires qw( has_progid progid good_load );
8             ###LogSD use Log::Shiras::Telephone;
9              
10             #########1 Dispatch Tables 3#########4#########5#########6#########7#########8#########9
11              
12              
13              
14             #########1 Public Attributes 3#########4#########5#########6#########7#########8#########9
15              
16              
17              
18             #########1 Public Methods 3#########4#########5#########6#########7#########8#########9
19              
20             sub load_unique_bits{
21 9     9 1 16 my( $self, ) = @_;
22             ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
23             ###LogSD $self->get_all_space . '::load_unique_bits', );
24             ###LogSD $phone->talk( level => 'debug', message => [
25             ###LogSD "Testing if the flat XML workbook opened correctly", $self->has_progid ] );
26              
27             # Check progid setting
28 9 100       256 if( !$self->has_progid ){
    50          
29             ###LogSD $phone->talk( level => 'warn', message => [
30             ###LogSD 'No progid recorded - bad xml base file' ] );
31 6         150 $self->good_load( 0 );
32             }elsif( $self->progid eq 'Excel.Sheet' ){
33             ###LogSD $phone->talk( level => 'debug', message => [
34             ###LogSD 'Found the correct progid: Excel.Sheet' ] );
35 3         78 $self->good_load( 1 );
36             }else{
37             ###LogSD $phone->talk( level => 'warn', message => [
38             ###LogSD 'Bad progid: ' . $self->progid ] );
39 0         0 $self->good_load( 0 );
40             }
41 9         21 return 1;
42             }
43              
44             #########1 Private Attributes 3#########4#########5#########6#########7#########8#########9
45              
46              
47              
48             #########1 Private Methods 3#########4#########5#########6#########7#########8#########9
49              
50              
51              
52             #########1 Phinish 3#########4#########5#########6#########7#########8#########9
53              
54 6     6   23620 no Moose::Role;
  6         10  
  6         29  
55             1;
56              
57             #########1 Documentation 3#########4#########5#########6#########7#########8#########9
58             __END__
59              
60             =head1 NAME
61              
62             Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookXML - Workbook flat XML file test
63              
64             =head1 SYNOPSIS
65              
66             #!/usr/bin/env perl
67             use MooseX::ShortCut::BuildInstance qw( build_instance );
68             use Spreadsheet::Reader::ExcelXML::XMLReader;
69             use Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookXML;
70             use Spreadsheet::Reader::ExcelXML::WorkbookFileInterface;
71             my $test_file = '../../../../t/test_files/TestBook.xml';
72             my $test_instance = build_instance(
73             package => 'WorkbookFileInterface',
74             superclasses => ['Spreadsheet::Reader::ExcelXML::XMLReader'],
75             add_roles_in_sequence =>[
76             'Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookXML',
77             'Spreadsheet::Reader::ExcelXML::WorkbookFileInterface',
78             ],
79             file => $test_file,
80             );
81             my $sub_file = $test_instance->extract_file( 'Styles' );
82             print $sub_file->getline;
83              
84             ###########################
85             # SYNOPSIS Screen Output
86             # 01: <?xml version="1.0"?><Styles><Style ss:ID="Default"/ ~~ / ss:ID="s22"><Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="14" ss:Color="#000000"
87             ###########################
88              
89             =head1 DESCRIPTION
90              
91             This documentation is written to explain ways to use this module when writing your own
92             excel parser. To use the general package for excel parsing out of the box please review
93             the documentation for L<Workbooks|Spreadsheet::Reader::ExcelXML>,
94             L<Worksheets|Spreadsheet::Reader::ExcelXML::Worksheet>, and
95             L<Cells|Spreadsheet::Reader::ExcelXML::Cell>
96              
97             This is the XML based file adaptor for reading the base xml flat file and determining
98             if it has the expected attribute in the mso-application header indicating it is a
99             L<SpreadsheetML|https://en.wikipedia.org/wiki/SpreadsheetML> format file. (
100             progid="Excel.Sheet" ) When combined with the generic XML reader and the
101             WorkbookFileInterface interface it makes a complete base xml flat file reader.
102              
103             =head2 Required Methods
104              
105             These are the methods required by the role. A link to the default implementation of
106             these methods is provided.
107              
108             L<Spreadsheet::Reader::ExcelXML::XMLReader/progid>
109              
110             L<Spreadsheet::Reader::ExcelXML::XMLReader/has_progid>
111              
112             L<Spreadsheet::Reader::ExcelXML::XMLReader/good_load( $state )>
113              
114             =head2 Methods
115              
116             These are the methods provided by this role (only).
117              
118             =head3 load_unique_bits
119              
120             =over
121              
122             B<Definition:> This role is meant to run on top of L<Spreadsheet::Reader::ExcelXML::XMLReader>.
123             When it does the reader will call this function as available when it first starts the file.
124             This particular version only tests for the correct attribute (progid="Excel.Sheet") in the
125             'mso-application' header.
126              
127             B<Accepts:> nothing
128              
129             B<Returns:> nothing
130              
131             =back
132              
133             =head1 SUPPORT
134              
135             =over
136              
137             L<github Spreadsheet::Reader::ExcelXML/issues
138             |https://github.com/jandrew/p5-spreadsheet-reader-excelxml/issues>
139              
140             =back
141              
142             =head1 TODO
143              
144             =over
145              
146             B<1.> Nothing currently
147              
148             =back
149              
150             =head1 AUTHOR
151              
152             =over
153              
154             =item Jed Lund
155              
156             =item jandrew@cpan.org
157              
158             =back
159              
160             =head1 COPYRIGHT
161              
162             This program is free software; you can redistribute
163             it and/or modify it under the same terms as Perl itself.
164              
165             The full text of the license can be found in the
166             LICENSE file included with this module.
167              
168             This software is copyrighted (c) 2016 by Jed Lund
169              
170             =head1 DEPENDENCIES
171              
172             =over
173              
174             L<Spreadsheet::Reader::ExcelXML> - the package
175              
176             =back
177              
178             =head1 SEE ALSO
179              
180             =over
181              
182             L<Spreadsheet::Read> - generic Spreadsheet reader
183              
184             L<Spreadsheet::ParseExcel> - Excel binary version 2003 and earlier (.xls files)
185              
186             L<Spreadsheet::XLSX> - Excel version 2007 and later
187              
188             L<Spreadsheet::ParseXLSX> - Excel version 2007 and later
189              
190             L<Log::Shiras|https://github.com/jandrew/Log-Shiras>
191              
192             =over
193              
194             All lines in this package that use Log::Shiras are commented out
195              
196             =back
197              
198             =back
199              
200             =cut
201              
202             #########1#########2 main pod documentation end 5#########6#########7#########8#########9