本文整理汇总了Python中odf.opendocument.OpenDocumentSpreadsheet.save方法的典型用法代码示例。如果您正苦于以下问题:Python OpenDocumentSpreadsheet.save方法的具体用法?Python OpenDocumentSpreadsheet.save怎么用?Python OpenDocumentSpreadsheet.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类odf.opendocument.OpenDocumentSpreadsheet
的用法示例。
在下文中一共展示了OpenDocumentSpreadsheet.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: output_reqset
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
def output_reqset(self, reqset, reqscont):
# Because of a problem with the current OpenOffice versions,
# there is the need to sometimes arrange requirements as rows
# and sometimes as columns:
# It is not possible to define the range of a list input as a
# row: it must be a column.
# The order dictionary holds the number - which can be
# computed in a row or column.
def create_reqs_index(srqes):
sreqs_index = {}
cnt = 0
for req in sreqs:
sreqs_index[req] = cnt
cnt += 1
return sreqs_index
# The topological sort is needed.
sreqs = topological_sort(self.topic_set.reqset)
# Create the row / column index of each requirement
self.sreqs_index = create_reqs_index(sreqs)
# Create and save the document
calcdoc = OpenDocumentSpreadsheet()
self.create_meta(calcdoc, reqscont)
self.create_styles(calcdoc)
self.create_costs_sheet(calcdoc, sreqs)
self.create_deps_sheet(calcdoc, sreqs)
self.create_sums_sheet(calcdoc, sreqs)
self.create_constants_sheet(calcdoc)
self.create_result_sheet(calcdoc, sreqs)
calcdoc.save(self.output_filename, True)
示例2: test_percentage
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
def test_percentage(self):
""" Test that an automatic style can refer to a PercentageStyle as a datastylename """
doc = OpenDocumentSpreadsheet()
nonze = PercentageStyle(name='N11')
nonze.addElement(Number(decimalplaces='2', minintegerdigits='1'))
nonze.addElement(Text(text='%'))
doc.automaticstyles.addElement(nonze)
pourcent = Style(name='pourcent', family='table-cell', datastylename='N11')
pourcent.addElement(ParagraphProperties(textalign='center'))
pourcent.addElement(TextProperties(attributes={'fontsize':"10pt",'fontweight':"bold", 'color':"#000000" }))
doc.automaticstyles.addElement(pourcent)
table = Table(name='sheet1')
tr = TableRow()
tc = TableCell(formula='=AVERAGE(C4:CB62)/2',stylename='pourcent', valuetype='percentage')
tr.addElement(tc)
table.addElement(tr)
doc.spreadsheet.addElement(table)
doc.save("TEST.odt")
self.saved = True
d = load("TEST.odt")
result = d.contentxml()
self.assertNotEqual(-1, result.find(u'''<number:percentage-style'''))
self.assertNotEqual(-1, result.find(u'''style:data-style-name="N11"'''))
self.assertNotEqual(-1, result.find(u'''style:name="pourcent"'''))
示例3: generate_ods
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
def generate_ods(data):
"""
Generate a ODS file.
:param data: list-like of dict with the data.
:return:
"""
doc = OpenDocumentSpreadsheet()
table = Table()
tr = TableRow()
colautowidth = Style(name="co1", family="table-column")
colautowidth.addElement(TableColumnProperties(useoptimalcolumnwidth=True))
doc.automaticstyles.addElement(colautowidth)
for column in data[0].keys():
table.addElement(TableColumn(stylename=colautowidth))
tc = TableCell(valuetype="string", value=column)
tc.addElement(P(text=column))
tr.addElement(tc)
table.addElement(tr)
for row in data:
tr = TableRow()
for column in row.keys():
tc = TableCell(valuetype="string", value=row[column])
tc.addElement(P(text=row[column]))
tr.addElement(tc)
table.addElement(tr)
file = os.path.join(tempfile.gettempdir(), 'SIGE' +
datetime.now().strftime('%Y%m%d%H%M%S%f') + '.ods')
doc.spreadsheet.addElement(table)
print(doc.automaticstyles.childNodes[0].attributes)
doc.save(file)
return file
示例4: calc
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
def calc(title, xlabel, ylabel, xdata, ydata):
from odf.opendocument import OpenDocumentSpreadsheet
from odf.text import P
from odf.table import Table, TableColumn, TableRow, TableCell
outfile = NamedTemporaryFile(
mode='wb',
suffix='.ods',
prefix='eyesCalc_',
delete=False)
doc=OpenDocumentSpreadsheet()
table = Table(name="ExpEYES {0}".format(time.strftime("%Y-%m-%d %Hh%Mm%Ss")))
doc.spreadsheet.addElement(table)
## add rows into the table
for i in range(len(xdata)):
tr = TableRow()
table.addElement(tr)
if len(ydata.shape)==1:
# single y data
tr.addElement(TableCell(valuetype="float", value=str(xdata[i])))
tr.addElement(TableCell(valuetype="float", value=str(ydata[i])))
else:
# multiple y data
tr.addElement(TableCell(valuetype="float", value=str(xdata[i])))
for j in range(ydata.shape[0]):
tr.addElement(TableCell(valuetype="float", value=str(ydata[j][i])))
doc.save(outfile)
outfile.close()
call("(localc {}&)".format(outfile.name), shell=True)
return [outfile]
示例5: _toODSFile
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
def _toODSFile(odf_table_list, filename):
doc = OpenDocumentSpreadsheet()
for t in odf_table_list:
doc.spreadsheet.addElement(t)
doc.save('/tmp/' + filename, True)
return file('/tmp/' + filename + '.ods')
示例6: save
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
def save(self, filename, i_max = None, j_max = None):
''' save table in ods format '''
if not i_max: i_max = self.table.i_max
if not j_max: j_max = self.table.j_max
# update cells text
self.table.updateTable(i_max, j_max)
# create new odf spreadsheet
odfdoc = OpenDocumentSpreadsheet()
# set direction style
rtl = Style(name = "dir", family = "table")
if self.table.direction == 'rtl':
rtl.addElement(TableProperties(writingmode="rl-tb"))
odfdoc.automaticstyles.addElement(rtl)
# create the table
table = Table(name = "sheet 1", stylename = 'dir')
# default style
ts = Style(name = "ts", family = "table-cell")
ts.addElement(TextProperties(fontfamily = SodsCell().font_family, fontsize = SodsCell().font_size))
odfdoc.styles.addElement(ts)
# create columns
for j in range(1, j_max):
colname = "col" + str(j)
c = self.table.getCellAt(0, j)
width = c.column_width
cs = Style(name = colname, family = "table-column")
cs.addElement(TableColumnProperties(columnwidth = width, breakbefore = "auto"))
odfdoc.automaticstyles.addElement(cs)
table.addElement(TableColumn(stylename = colname, defaultcellstylename = "ts"))
# make sure values are up to date
# loop and update the cells value
for i in range(1, i_max):
# create new ods row
tr = TableRow()
table.addElement(tr)
# create default data styles for dates and numbers
ncs = NumberStyle(name="ncs")
ncs.addElement(Number(decimalplaces="2", minintegerdigits="1", grouping="true"))
odfdoc.styles.addElement(ncs)
ncs2 = NumberStyle(name="ncs2")
ncs2.addElement(Number(decimalplaces="0", minintegerdigits="1", grouping="false"))
odfdoc.styles.addElement(ncs2)
dcs = DateStyle(name="dcs")
dcs.addElement(Year(style='long'))
dcs.addElement(Text(text = u'-'))
dcs.addElement(Month(style='long'))
dcs.addElement(Text(text = u'-'))
dcs.addElement(Day(style='long'))
odfdoc.styles.addElement(dcs)
for j in range(1, j_max):
# update the cell text and condition
cell = self.table.encodeColName(j) + str(i)
c = self.table.getCellAt(i, j)
# chose datastylename
if c.value_type == 'date':
datastylename = "dcs"
else:
if c.format == "":
datastylename = "ncs2"
if c.format == "#,##0.00":
datastylename = "ncs"
# get cell style id
if (c.condition):
style_id = (datastylename + c.color + c.font_size + c.font_family +
c.background_color + c.border_top + c.border_bottom +
c.border_left + c.border_right +
c.condition_color + c.condition_background_color)
else:
style_id = (datastylename + c.color + c.font_size + c.font_family +
c.background_color + c.border_top + c.border_bottom +
c.border_left + c.border_right)
# set ods style
style_name = self.getStyle(c, cell, datastylename, style_id, odfdoc)
# create new ods cell
if (c.formula and c.formula[0] == '=' and c.formula[:4] != '=uni'):
if self.table.isFloat(c.value):
tc = TableCell(valuetype = c.value_type,
formula = c.formula, value = float(c.value), stylename = style_name)
else:
tc = TableCell(valuetype = c.value_type,
formula = c.formula,
value = 0, stylename = style_name)
elif (c.value_type == 'date'):
tc = TableCell(valuetype = c.value_type,
#.........这里部分代码省略.........
示例7: odsResponse
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
def odsResponse(inscriptions, noninscrits):
"""
fabrique un objet de type HttpResponse qui comporte un tableur au format
ODS, avec les exportations d'une "barrette" d'AP.
@param inscriptions un objet issu de Inscription.objects.all()
@param noninscrits une liste d'Etudiants
@return un objet de type HttpResponse
"""
response = HttpResponse(content_type='application/vnd.oasis.opendocument.spreadsheet')
now=timezone.now()
filename="aperho-{}.ods".format(now.strftime("%Y%m%d-%H%M"))
response['Content-Disposition'] = 'attachment; filename={}'.format(filename)
doc = OpenDocumentSpreadsheet()
# Create a style for the table content. One we can modify
# later in the word processor.
tablecontents = Style(name="Table Contents", family="paragraph")
tablecontents.addElement(ParagraphProperties(numberlines="false", linenumber="0"))
tablecontents.addElement(TextProperties(fontweight="bold"))
doc.styles.addElement(tablecontents)
# Create automatic styles for the column widths.
# We want two different widths, one in inches, the other one in metric.
# ODF Standard section 15.9.1
widthshort = Style(name="Wshort", family="table-column")
widthshort.addElement(TableColumnProperties(columnwidth="1.7cm"))
doc.automaticstyles.addElement(widthshort)
widthwide = Style(name="Wwide", family="table-column")
widthwide.addElement(TableColumnProperties(columnwidth="1.5in"))
doc.automaticstyles.addElement(widthwide)
# Start the table, and describe the columns
table = Table(name="Inscriptions")
table.addElement(TableColumn(numbercolumnsrepeated=3,stylename=widthwide))
tr = TableRow()
table.addElement(tr)
for title in ['id', 'Eleve_nom', 'Eleve_prenom', 'Eleve_classe', 'Professeur', 'Salle', 'Heure', 'Duree', 'Public_designe', 'Resume','Detail','Autres']:
tc = TableCell()
tr.addElement(tc)
p = P(stylename=tablecontents,text=title)
tc.addElement(p)
for i in inscriptions:
tr = TableRow()
table.addElement(tr)
for val in [i.pk, i.etudiant.nom, i.etudiant.prenom, i.etudiant.classe, i.cours.enseignant.nom, i.cours.enseignant.salle, i.cours.horaire, i.cours.formation.duree, i.cours.formation.public_designe, i.cours.formation.titre, i.cours.formation.contenu]:
tc = TableCell()
tr.addElement(tc)
p = P(stylename=tablecontents,text=str(val))
tc.addElement(p)
## write something in the last column (Autres)
tc = TableCell()
tr.addElement(tc)
p = P(stylename=tablecontents,text=rdvOrientation(i))
tc.addElement(p)
for e in noninscrits:
tr = TableRow()
table.addElement(tr)
for val in [0, e.nom, e.prenom, e.classe, '', '', '', '', '', '', '','']:
tc = TableCell()
tr.addElement(tc)
p = P(stylename=tablecontents,text=str(val))
tc.addElement(p)
doc.spreadsheet.addElement(table)
output=BytesIO()
doc.save(output)
response.write(output.getvalue())
return response
示例8: Style
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
# ODF Standard section 15.9.1
widthshort = Style(name="Wshort", family="table-column")
widthshort.addElement(TableColumnProperties(columnwidth="1.7cm"))
doc.automaticstyles.addElement(widthshort)
widthwide = Style(name="Wwide", family="table-column")
widthwide.addElement(TableColumnProperties(columnwidth="1.5in"))
doc.automaticstyles.addElement(widthwide)
# chenyang20140702-start
# create style for big title
bigtitle = Style(name="Large number", family="table-cell")
bigtitle.addElement(TextProperties(fontfamily="WenQuanYi Micro Hei", fontsize="20pt", fontsizeasian="50pt"))
bigtitle.addElement(TableColumnProperties(columnwidth="17cm"))
doc.styles.addElement(bigtitle)
# chenyang20140702-end
# Start the table, and describe the columns
table = Table(name="big_title")
#table.addElement(TableColumn(numbercolumnsrepeated=4,stylename=widthshort))
#table.addElement(TableColumn(numbercolumnsrepeated=3,stylename=widthwide))
# glue start
tr = TableRow()
table.addElement(tr)
cell(tr, "a部b门主c管", bigtitle)
# glue end
doc.spreadsheet.addElement(table)
doc.save("big_title", True)
示例9: create_ods
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
def create_ods(filename):
doc = OpenDocumentSpreadsheet()
# doc.spreadsheet.addElement(table)
# doc.save(filename, True) # add "ods" as suffix
doc.save(filename) # not add "ods" as suffix
示例10: __init__
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
#.........这里部分代码省略.........
tc.addElement(p)
def generate_ods(self, path="/home/apkawa/work/test_desu", group=False):
self.make_style( tablename = self.category.name )
self.add_spanned_row( (u'OOO "Политехник"',), self.head )
head = (
( u'phone:','+7 (812) 312-42-38'),
( u'','+7 (812) 970-42-93'),
( u'email:','[email protected]'),
( u'www:','http://polytechnik.ru'),
('',),
)
self.add_rows( head, self.head )
self.add_row( ( u'Прайс от %s'%date,), self.root_style )
self.add_spanned_row( (self.category.name, ), self.tablemanuf )
self.add_row( ( u'Наименование',u'Описание',u'Цена',), self.tablehead )
manuf = None
type_product = 13
for p in self.price:
if manuf != p.manufacturer_id and p.manufacturer_id != 233:
manuf = p.manufacturer.id
self.add_spanned_row( (p.manufacturer.name,) , self.tablemanuf )
if type_product != p.type_product_id and p.type_product_id != 13:
type_product = p.type_product_id
self.add_spanned_row( ( p.type_product.name,) , self.tablemanuf )
p_desc = p.desc
p_cell = ' %.0f %s'%(p.cell, p.valyuta.desc) if p.cell else ' -'
if p_desc:
self.add_row( ( p.name, p_desc, p_cell ) , self.tablecontents )
elif not p.desc and not p.cell:
p_name = re.sub('(<h4>|</h4>)','',p.name)
self.add_spanned_row( (p_name,), self.tablehead )
else:
tr = TableRow( stylename = self.tablecontents )
self.table.addElement(tr)
p_price = ( p.name, p_cell )
#self.add_cell( pl, tr, self.tablecontents, )#numbercolumnsspanned=2, numberrowsspanned = 1 )
tc = TableCell( stylename= self.tablecontents, numbercolumnsspanned=2, numberrowsspanned = 1 )
tr.addElement(tc)
p = P(text=p_price[0])
tc.addElement(p)
tr.addElement( CoveredTableCell() )
self.add_cell( p_price[1], tr, self.tablecontents )
self.doc.spreadsheet.addElement( self.table )
self.doc.save( path , True)
def read_stdout(self):
print 'name; desc;cell; manuf;pos;type_product;pos;category_id; img_url'
manuf = None
type_product = None
for p in self.price:
if manuf != p.manufacturer_id and p.manufacturer_id != 233:
manuf = p.manufacturer.id
print '"%s";"%s";\n'%(p.manufacturer.name,p.manufacturer.pos if p.manufacturer.pos else '')
if type_product != p.type_product_id and p.type_product_id != 13:
type_product = p.type_product_id
print '"%s";"%s";\n'%(p.type_product.name, p.type_product.pos if p.type_product.pos else '' )
# 0 1 2 3 4 5 6 7 8
#name_pr desc cell manuf pos type_product pos category_id img_flag
print '"%s";"%s";"%s";"%s";"%s";"%s";"%s";"%s";"%s";'%(p.name,
p.desc if p.desc else '',
'%.0f %s'%(p.cell, p.valyuta.desc),
p.manufacturer.name,
p.manufacturer.pos,
p.type_product.name,
p.type_product.pos,
p.category_id,
p.img_url if p.img_url else '')
def connect_base(self, category_id = 202, manufac_name = False):
self.base = []
self.category = Category.objects.get(id= category_id )
if manufac_name and type(manufac_name) == type([]):
self.price = Price.objects.filter(
category = self.category, manufacturer__name__in = manufac_name ).order_by(
'manufacturer__pos','manufacturer', 'type_product__pos','type_product','id' )
elif manufac_name:
self.price = Price.objects.filter(
category = self.category, manufacturer__name = manufac_name ).order_by(
'manufacturer__pos','manufacturer', 'type_product__pos','type_product','id' )
else:
self.price = Price.objects.filter( category = self.category ).order_by( 'manufacturer__pos','manufacturer',
'type_product__pos','type_product','id' )
if not self.price.count():
return False
else:
return True
示例11: load
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
if upd:
table_media = None
table_desvio = None
try:
doc = load(out_file + ".ods")
except:
print "File not found? (%s)" % (out_file + ".ods")
sys.exit(2)
for sheet in doc.getElementsByType(Table)[:]:
if sheet.attributes['table:name'] == db_name + "_media":
table_media = sheet
if sheet.attributes['table:name'] == db_name + "_desvio":
table_desvio = sheet
if not (table_media and table_desvio):
table_media = Table(name=db_name + "_media")
table_desvio = Table(name=db_name + "_desvio")
make_body(dir,desc)
doc.spreadsheet.addElement(table_media)
doc.spreadsheet.addElement(table_desvio)
else:
make_body(dir,desc)
doc.save(out_file, True)
else:
doc = OpenDocumentSpreadsheet()
table_media = Table(name=db_name + "_media")
table_desvio = Table(name=db_name + "_desvio")
make_body(dir,desc)
doc.spreadsheet.addElement(table_media)
doc.spreadsheet.addElement(table_desvio)
doc.save(out_file, True)
示例12: isinstance
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
if f_type == 'many2one':
d = d and d[1] or ''
elif f_type == 'many2many':
d = ','.join(map(str, d))
elif f_type == 'one2many':
d = ','.join(map(str, d))
if isinstance(d, int):
tc = TableCell(valuetype="int", value=d)
elif isinstance(d, float):
tc = TableCell(valuetype="float", value=d)
elif isinstance(d, bool):
tc = TableCell(valuetype="bool", value=d)
else:
tc = TableCell(valuetype='string')
tr.addElement(tc)
if isinstance(d, unicode):
p = P(stylename=tablecontents, text=d)
else:
p = P(stylename=tablecontents, text=unicode(str(d), 'utf-8'))
tc.addElement(p)
cpt += 1
textdoc.spreadsheet.addElement(table)
textdoc.save(opts.filename)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
示例13: oopricing1
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
#.........这里部分代码省略.........
# The version for read-only.
s = odf.style.Style(name="col-int", family="table-cell",
datastylename="ns-int")
self.__calcdoc.automaticstyles.addElement(s)
self.doc_styles["col-int"] = s
# And the same for rw.
s = odf.style.Style(name="col-int-rw", family="table-cell",
datastylename="ns-int")
s.addElement(odf.style.TableCellProperties(cellprotect="none",
printcontent="true"))
self.__calcdoc.automaticstyles.addElement(s)
self.doc_styles["col-int-rw"] = s
def __create_styles(self):
'''There is the need to apply some styles.'''
# There is the need for many different styles.
self.__create_styles_table_cell()
self.__create_styles_table_column()
self.__create_styles_currency()
self.__create_styles_int()
def topic_set_pre(self, topics_set):
'''Document setup and output.
Because for this document a very specific sort order
must be implemented, everything must be done here explicitly -
the executor interface can only partially be used.'''
self.__calcdoc = OpenDocumentSpreadsheet()
self.__create_meta()
self.__create_styles()
def topic_set_post(self, topics_set):
'''Document storage.'''
self.__calcdoc.save(self._output_filename, True)
# Sheet creation functions.
def __create_costs_sheet(self, sreqs):
sheet = odf.table.Table(name="Costs", protected="true")
self.create_form(sheet, sreqs)
self.create_costs_column_styles(sheet)
self.create_costs_header(sheet, sreqs[0])
self.create_costs_content(sheet, sreqs)
self.__calcdoc.spreadsheet.addElement(sheet)
def __create_deps_sheet(self, sreqs):
sheet = odf.table.Table(name="Deps") #, protected="true")
self.create_reqs_ids_row(sheet, sreqs)
# The second row is where all the results will be inserted.
# Therefore put in each one a none.
tr = odf.table.TableRow()
for _ in sreqs:
self.create_text_cell(tr, "none")
sheet.addElement(tr)
# The third row contains the indices of the requirement
# which is chosen as the dependent one.
tr = odf.table.TableRow()
for req in sreqs:
tc = odf.table.TableCell()
if req.get_incoming_cnt() > 0:
# By default, the chosen is the first one.
p = odf.text.P(text=req.get_iter_incoming().next().get_name())
tc.addElement(p)
tr.addElement(tc)
sheet.addElement(tr)
示例14: Style
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
ns2.addElement(Number(decimalplaces="2", minintegerdigits="1", grouping="true"))
ns2.addElement(Map(condition="value()>=0", applystylename="positive-AUD"))
textdoc.styles.addElement(ns2)
# Create automatic style for the price cells.
moneycontents = Style(name="ce1", family="table-cell", parentstylename=tablecontents, datastylename="main-AUD")
textdoc.automaticstyles.addElement(moneycontents)
# Start the table, and describe the columns
table = Table(name="Currency colours")
# Create a column (same as <col> in HTML) Make all cells in column default to currency
table.addElement(TableColumn(stylename=widewidth, defaultcellstylename="ce1"))
# Create a row (same as <tr> in HTML)
tr = TableRow()
table.addElement(tr)
# Create a cell with a negative value. It should show as red.
cell = TableCell(valuetype="currency", currency="AUD", value="-125")
cell.addElement(P(text=u"$-125.00")) # The current displayed value
tr.addElement(cell)
# Create a row (same as <tr> in HTML)
tr = TableRow()
table.addElement(tr)
# Create another cell but with a positive value. It should show in black
cell = TableCell(valuetype="currency", currency="AUD", value="123")
cell.addElement(P(text=u"$123.00")) # The current displayed value
tr.addElement(cell)
textdoc.spreadsheet.addElement(table)
textdoc.save("currency.ods")
示例15: TableRow
# 需要导入模块: from odf.opendocument import OpenDocumentSpreadsheet [as 别名]
# 或者: from odf.opendocument.OpenDocumentSpreadsheet import save [as 别名]
if number_rows_spanned > 1:
first_cell.setAttribute("numberrowsspanned", number_rows_spanned)
for error in errors:
tr = TableRow()
tc = TableCell()
tc.addElement(P(text=error))
table.addElement(tr)
tr.addElement(tc)
for examinee in undefined:
tr = TableRow()
table.addElement(tr)
tc = TableCell(stylename=middle_center)
tr.addElement(tc)
tc.addElement(P(text=undefined[examinee][0]))
tc = TableCell(stylename=middle_center)
tr.addElement(tc)
tc = TableCell(stylename=middle_left)
tr.addElement(tc)
tc.addElement(P(text=examinee))
for examiner in homogenize(undefined[examinee][1]):
tc = TableCell(stylename=middle_center)
tr.addElement(tc)
tc.addElement(P(text=examiner))
output.spreadsheet.addElement(table)
name, ext = splitext(argv[1])
output.save(name+"-timetable"+ext)