Spreadsheet-WriteExcelXML
view release on metacpan or search on metacpan
lib/Spreadsheet/WriteExcelXML/XMLwriter.pm view on Meta::CPAN
$self->{_indentation} = defined $_[0] ? $_[0] : ' ';
}
1;
__END__
=head1 NAME
XMLwriter - A base class for Excel workbooks and worksheets.
=head1 SYNOPSIS
#!/usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcelXML::XMLwriter;
my $writer = Spreadsheet::WriteExcelXML::XMLwriter->new(*STDOUT);
$writer->_write_xml_start_tag(0, 1, 0, 'Table', 'Rows', 4, 'Cols', 2);
$writer->_write_xml_element (1, 1, 0, 'Row', 'Index', '1');
$writer->_write_xml_end_tag (0, 1, 0, 'Table');
__END__
Prints:
<Table Rows="4" Cols="2">
<Row Index="1"/>
</Table>
=head1 DESCRIPTION
This module is used in conjunction with Spreadsheet::WriteExcelXML. It is not intended to be a general purpose module.
As such this documentation is intended mainly for Spreadsheet::WriteExcelXML developers and maintainers.
=head1 METHODS
This section describes the methods of the C<Spreadsheet::WriteExcelXML::XMLwriter> module.
=head2 set_indentation()
The C<set_indentation()> method is used to define the style of indentation used in the output from C<Spreadsheet::WriteExcelXML::XMLwriter>. This is the only C<public> method of the module.
The default indentation style is four spaces. Calling C<set_indentation()> with C<undef> or no argument will set the indentation style back to the default.
A special case argument is the null string C<''>. In addition to not adding any indentation this also overrides any newline settings so that the output is as compact as possible and in the form of a single line. This is useful for saving space or whe...
The following example shows some of the options:
#!/usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcelXML::XMLwriter;
my $writer = Spreadsheet::WriteExcelXML::XMLwriter->new(*STDOUT);
# One space indent.
$writer->set_indentation(' ');
$writer->_write_xml_start_tag(1, 1, 1, 'Table');
$writer->_write_xml_start_tag(2, 1, 1, 'Row' );
$writer->_write_xml_start_tag(3, 1, 1, 'Cell' );
print "\n";
# Undef. Four space indent, the default.
$writer->set_indentation();
$writer->_write_xml_start_tag(1, 1, 1, 'Table');
$writer->_write_xml_start_tag(2, 1, 1, 'Row' );
$writer->_write_xml_start_tag(3, 1, 1, 'Cell' );
print "\n";
# Empty string. No indentation or newlines.
$writer->set_indentation('');
$writer->_write_xml_start_tag(1, 1, 1, 'Table');
$writer->_write_xml_start_tag(2, 1, 1, 'Row' );
$writer->_write_xml_start_tag(3, 1, 1, 'Cell' );
print "\n";
The output is as follows. Spaces shown as C<.> for clarity.
.<Table>
..<Row>
...<Cell>
....<Table>
........<Row>
............<Cell>
<Table><Row><Cell>
=head2 _format_tag($level, $nl, $list, @attributes)
This function formats an XML element tag for printing. This is a C<private> method used by the C<_write_xml_xxx> methods. The C<_write_xml_xxx> methods can be considered as C<protected> and share the same parameters as C<_format_tag()>.
The parameters are as follows:
=over 4
=item C<$level>
The C<$level> parameter sets the indentation level. The type of indentation is defined using the set_indentation() method.
( run in 1.654 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )