odsgen
Open Document spreadsheet generation library
====== odsgen ====== Odsgen is a thin wrapper around odfpy that makes it easy to generate simple Open Document Spreadsheet files. Usage ===== Create a new document and add a sheet to it:: import odsgen doc = odsgen.Document() table = doc.add_table(name=u'Sheet1') Then add some rows to it:: table.add_row([1, 2, 3]) table.add_row([u'a', u'b', u'c']) You can also add cells to an existing row:: row = table.add_row([7, 8, 9]) row.add_cell(u'd') row.add_cells([u'e', u'f']) Add some formatting attributes:: table.add_row([u"Header", u"text", u"is", u"bold"], fontweight='bold') Declare column attributes:: table.add_column(columnwidth='7.5cm') Write the document to a file:: with open('spreadsheet.ods', 'w') as f: doc.write(f) Formatting ========== Formatting is done with attributes passed to the `add_row`, `add_cell`, `add_cells` and `add_column` methods. The attribute names come directly from the odfpy package which, in turn, takes them from the ODF specification. For convenience, if cell attributes are passed to `add_row`, they are applied to every cell in the row by default. Cell attributes --------------- valuetype One of `boolean`, `currency`, `date`, `float`, `percentage`, `string`, `time` or `void`. backgroundcolor Cell background color. "transparent" or a color in the format "#rrggbb". color Text color border Cell border. The value is made of three optional parts separated by spaces. The first part is the border width, in `pt`, `cm` or `in`. The second part is the border style, one of `none`, `hidden`, `dotted`, `dashed`, `solid`, `double`, `groove`, `ridge`, `inset` or `outset`. The third part is the border color in "#rrggbb" format. It is also possible to specify different borders on each side of the cell using the `borderbottom`, `borderleft`, `borderright` and `bordertop` borderlinewidth Width of borders defined by the `border*` attributes when their value is "double". It is a list of three whitespace-separated lengths wher the first value is the width of the inner line, the second value is the distance between the two lines and the third value is the width of the outer line. Those widths can also be specified using the `borderlinewidthbottom`, `borderlinewidthleft`, `borderlinewidthright` and `borderlinewidthtop` attributes. padding Cell padding, in `pt`, `cm` or `in`. Padding on each side of the cell can be specified using the `paddingbottom`, `paddingleft`, `paddingright` and `paddingtop` attributes. wrapoption Whether or not to wrap text in the cell. `wrap` or `no-wrap`. cellprotect How a cell is protected. This is valid only if the table is protected. The defined values are: * `formula-hidden`: if cell content is a formula, it is not displayed. It can be replaced by changing the cell content. * `hidden-and-protected`: cell content is not displayed and cannot be edited. If content is a formula, the formula result is not displayed. * `none`: formula responsible for cell content is neither hidden nor protected. * `protected`: cell content can not be edited. * `protected formula-hidden`: cell content can not be edited. If content is a formula, it is not displayed. A formula result is displayed. decimalplaces Maximum number of decimal places displayed. grouping Whether or not to separate thousands. Value is `true` or `false`. diagonalbltr, diagonaltlbr Style for a bottom-left to top-right or top-left to bottom-right diagonal, in the form of a CSS border property. diagonalbltrwidths, diagonaltlbrwidths Widths of a double diagonal, in the same format as the `borderlinewidths` attribute. direction Direction of characters. * `ltr` for left to right * `ttb` for top to bottom writingmode Values are `lr-tb`, `rl-tb`, `tb-rl`, `tb-lr`, `lr`, `rl`, `tb` or `page`. glyphorientationvertical Values are `auto` or `0` printcontent Whether or not the cell content is printed. Values are `true` or `false`. repeatcontent Whether or not the content of the cell is displayed as many times as there is space left in the cell. Values are `true` or `false`. rotationangle Rotation angle of the cell. The value is an angle followed by one of the following units: `deg`, `grad` or `rad`. rotationalign How the edge of the text is aligned after a rotation. Values are `none`, `bottom`, `top` or `center`. shrinktofit Whether or not the content should be shrinked to fit the cell size. Values are `true` or `false`. textalignsource Whether or not to use the `textalign` attribute to determine the horizontal alignement or not. Values are: * `fix`: align according to the `textalign` attribute. * `value-type`: align strings left and other types right. verticalalign Vertical alignment of the cell. Values are `automatic`, `bottom`, `middle` or `top`. hyphenate Whether or not to hyphenate. Values are `true` or `false`. hyphenationpushcharcount, hyphenationremaincharcount Minimum number of characters that can be left to remain on the line or pushed to the next line during hyphenation. Row attributes -------------- backgroundcolor Backgrond color for the whole row Column attributes ----------------- numbercolumnsrepeated Repeats this column a number of times. columnwidth Column width in `pt`, `cm` or `in`.Filename | Platform | Type | Version | Uploaded On | Size |
---|---|---|---|---|---|
odsgen-0.6.tar.gz | Source | 0.6 | 2014-01-30 11:09:38 | 5.4 KB | |
odsgen-0.5.tar.gz | Source | 0.5 | 2013-11-19 09:59:52 | 5.4 KB | |
odsgen-0.4.tar.gz | Source | 0.4 | 2013-08-26 14:00:56 | 5.4 KB | |
odsgen-0.3.tar.gz | Source | 0.3 | 2013-01-25 19:36:00 | 3.4 KB | |
odsgen-0.2.tar.gz | Source | 0.2 | 2012-08-31 19:59:45 | 3.2 KB | |
odsgen-0.1.tar.gz | Source | 0.1 | 2012-06-15 13:07:44 | 2.4 KB |
- License:
- Author: Eric Mc Sween
- Home Page: http://pypi.auf.org/odsgen
- Download URL:
- Classifiers:
- License :: OSI Approved :: MIT License
- Topic :: Office/Business :: Financial :: Spreadsheet