Spreadsheet::WriteExcel::FromXML - Create Excel Spreadsheet from XML
use strict; use warnings; use Spreadsheet::WriteExcel::FromXML; my $fromxml = Spreadsheet::WriteExcel::FromXML->new( "file.xml" ); $fromxml->parse; $fromxml->buildSpreadsheet; $fromxml->writeFile("file.xls"); # or my $data = $fromxml->getSpreadsheetData; # then write $data to a file...or do with it as you wish # or, even simpler: my $data = Spreadsheet::WriteExcel::FromXML->BuildSpreadsheet( "file.xml" ); # or, even simpler: Spreadsheet::WriteExcel::FromXML->XMLToXLS( "file.xml", "file.xls" );
This module uses Spreadsheet::WriteExcel to turn a simple XML data file into a binary Excel XLS file.
See also the FromXML.dtd file in the distribution.
Param: XML file name - name of file to be parsed. Return: ToExcel object.
Constructor. Optionally takes an XML file name.
Param: XML file source (GLOB, IO::Handle, file name or XML as a string [or scalar ref]) Return: true Throws: exception if unable to
Initializer method to check for existance of the XML file.
Param: XML file name or an IO::Handle [optional]. Return: true Throws: exception if xmlsource initialization fails, or if parsing fails
A method to make the necessary calls to parse the XML file. Remember, if a file handle is passed in the calling code is responsible for closing it.
Param: none. Return: true
A method to parse an XML file into a tree-style data structure using XML::Parser.
Param: $ar - child xml elements Param: $xmltag - the xml tag name (string) Param: $rownum - the current row number in the internal worksheet Param: $column - the current column number in the current row Param: $rowformat Return: void.
A method for taking the tree-style data structure from XML::Parser and sticking the data into our object structure & Spreadsheet::WriteExcel. After this method is called, we have an Excel spreadsheet ready for output.
Param: filename - file name to output Excel data to. Return: true/false Throws: exception if unable to open the file.
writeFile takes a file name and writes the XLS data from the internal buffer to the specified file.
Once the spreadsheet has been generated, this method returns the binary representation of the spreadsheet.
Get/set method to reference our Workbook object.
Get/set method for the raw XML tree data.
Get/set method for the XML file that is being parsed.
Get/set method for large (>7mb) Excel spreadsheets. If set, the code will make the appriopriate calls to build a spreadsheet >7mb. This requires a patch to OLE::Storage_Lite.
W. Justin Bedard juice [at] lerch.org
Kyle R. Burton mortis [at] voicenet.com, krburton [at] cpan.org