The global Configuration object provides several configuration methods.
Set the global Spreadsheet/Table expand strategy for repeated rows and columns.
Parameters: |
|
---|
Reset the global Spreadsheet/Table expand strategy for repeated rows and columns. Set strategy to 'all_less_maxcount' and maxcount to (32, 32).
Parameters: | filename (str) – a filename or the file-content as bytes |
---|---|
Returns: | PackagedDocument or FlatXMLDocument |
Open the document filename. Returns an instance of the PackagedDocument class, if the file is a zip-packed document, or an instance of the FlatXMLDocument class, if the document is a single-XML-file document. The document type is determined by the file content.
If you have no access to the filesystem, pass the content of the zip-file (type bytes) as filename parameter. The save() method still works, but no backups will be created.
You can check the document type by the doctype or the mimetype attribute.
Desktop applications often adding many empty rows and/or empty columns and this library has a very simple cell management strategy - every cell is represented in RAM in a 2-dimensional array - which can fill the whole memory. I have added three different opening strategies for spreadsheets and tables to prevent a memory overflow.
Because loading spreadsheets is an automatic class wrapping process and there is no simple way to pass additional parameters to the opening process (a library design error, sorry), you have to configure the opening strategy by the Global Configuration object.
The three strategies are:
Warning
Only the strategy 'all' guarantee the original spreadsheet layout, the other two strategies can break cell references and other strange things can happen, but in most cases they only remove unnecessary appended rows and columns.
example:
import ezodf
# if it is necessary to expand all rows/columns
ezodf.config.set_table_expand_strategy('all')
spreadsheet = ezodf.opendoc('expand_all_cells.ods')
# advice: always reset table expanding strategy
ezodf.config.reset_table_expand_strategy()
Parameters: |
|
---|---|
Returns: |
Create a new ODF Document. Returns always an instance of the PackagedDocument class.
If you have no access to the filesystem, pass the content of the zip-file (type bytes) as filename parameter.
Doctype | Mimetype |
---|---|
odt | application/vnd.oasis.opendocument.text |
ott | application/vnd.oasis.opendocument.text-template |
odg | application/vnd.oasis.opendocument.graphics |
otg | application/vnd.oasis.opendocument.graphics-template |
odp | application/vnd.oasis.opendocument.presentation |
otp | application/vnd.oasis.opendocument.presentation-template |
ods | application/vnd.oasis.opendocument.spreadsheet |
ots | application/vnd.oasis.opendocument.spreadsheet-template |
odc | application/vnd.oasis.opendocument.chart |
otc | application/vnd.oasis.opendocument.chart-template |
odi | application/vnd.oasis.opendocument.image |
oti | application/vnd.oasis.opendocument.image-template |
odf | application/vnd.oasis.opendocument.formula |
otf | application/vnd.oasis.opendocument.formula-template |
odm | application/vnd.oasis.opendocument.text-master |
oth | application/vnd.oasis.opendocument.text-web |
I use the lxml package to manage the XML data. You have access to the lxml Elements by the xmlnode attribute in all ODF Content Wrapper classes which bases on the GenericWrapper class.
All document classes have the attributes meta, styles, manifest, content and body and each of them have a xmlnode attribute to the XML representation of the associated XML files manifest.xml, styles.xml, meta.xml and content.xml.