ods
Class for reading and writing OpenDocument Spreadsheet files.
Example code to create an ODS file:
$oOds = new ods();
$oOds->addCell(0,0,0,1,'float'); //add a cell to sheet 0, row 0, cell 0, with value 1 and type float
$oOds->addCell(0,0,1,2,'float'); //add a cell to sheet 0, row 0, cell 1, with value 1 and type float
$oOds->addCell(0,1,0,1,'float'); //add a cell to sheet 0, row 1, cell 0, with value 1 and type float
$oOds->addCell(0,1,1,2,'float'); //add a cell to sheet 0, row 1, cell 1, with value 1 and type float
$oOds->save('/path/to/file.ods', 'en-US');
Example code to read a previously created ODS file:
$oOds = new ods();
$oOds->loadFromFile('/path/to/file.ods');
// do stuff with data
Changes made by Dave Redfern:
public __construct([$inFilename = null], [$inLanguage = 'en-US'])
Creates a new ODS object, if $inFilename is specified and exists it will be loaded
public static getInstance([$inFilename = null])
Returns a new empty ODS instance
public loadFromFile($inFile)
Loads the data from $inFile into the class, requires zip:// fopen wrapper
public loadFromString($inXmlString)
Loads the data from $inXmlString into the class
public save([$inFile = null], [$inLanguage = null])
Saves the current data to $inFile location
public addCell($sheet, $row, $cell, $value, $type)
Adds a cell to the specified sheet
public editCell($sheet, $row, $cell, $value)
Edit the cell contents, must be same format as loaded cell
public removeCell($sheet, $row, $cell)
Removes the cell from the specified sheet at row and cell.
public getFilename()
Returns $_Filename
public setFilename($inFilename)
Set $_Filename to $inFilename
public getLanguage()
Returns $_Language
public setLanguage($inLanguage)
Set language for file, language should be specified as xx-YY e.g. en-GB, es-ES
private _arrayToOds()
Converts the internal arrays into an ODS data stream
private _parse($data)
Parses the ODS XML data into a structure that can be manipulated by PHP
private _startElement($parser, $tagName, $attrs)
XML Parser start element handler
private _endElement($parser, $tagName)
XML Parser end element handler
private _characterData($parser, $data)
Character data handler
private _getMeta($lang)
Returns the meta data XML descriptor
private _getStyle()
Returns the style XML descriptor
private _getSettings()
Returns the ODS settings
private _getManifest()
Returns the ODS manifest data
Posted by: Scorpio Documentor (Writer), in Documentation on 19 Nov 2009 @ 20:31
Tags: ods, opendocument, spreadsheet,
This
work is licenced under a
Creative Commons Licence.