本文整理汇总了Python中odf.table.TableCell.setAttrNS方法的典型用法代码示例。如果您正苦于以下问题:Python TableCell.setAttrNS方法的具体用法?Python TableCell.setAttrNS怎么用?Python TableCell.setAttrNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类odf.table.TableCell
的用法示例。
在下文中一共展示了TableCell.setAttrNS方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_title
# 需要导入模块: from odf.table import TableCell [as 别名]
# 或者: from odf.table.TableCell import setAttrNS [as 别名]
def add_title(self, title, width):
row = TableRow()
cell = TableCell(stylename="title")
cell.setAttrNS(TABLENS, "number-columns-spanned", width)
cell.addElement(P(text=title))
row.addElement(cell)
self.sheet.addElement(row)
示例2: write_cell
# 需要导入模块: from odf.table import TableCell [as 别名]
# 或者: from odf.table.TableCell import setAttrNS [as 别名]
def write_cell(self, row, x):
tc = TableCell()
x_type = type(x)
x_odf_type = ODS_WRITE_FORMAT_COVERSION.get(x_type, "string")
tc.setAttrNS(OFFICENS, "value-type", x_odf_type)
x_odf_value_token = VALUE_TOKEN.get(x_odf_type, "value")
converter = ODS_VALUE_CONVERTERS.get(x_odf_type, None)
if converter:
x = converter(x)
if x_odf_type != 'string':
tc.setAttrNS(OFFICENS, x_odf_value_token, x)
tc.addElement(P(text=x))
row.addElement(tc)
示例3: write_cell
# 需要导入模块: from odf.table import TableCell [as 别名]
# 或者: from odf.table.TableCell import setAttrNS [as 别名]
def write_cell(self, row, cell):
tc = TableCell()
cell_type = type(cell)
cell_odf_type = ODS_WRITE_FORMAT_COVERSION.get(cell_type, "string")
tc.setAttrNS(OFFICENS, "value-type", cell_odf_type)
cell_odf_value_token = VALUE_TOKEN.get(cell_odf_type, "value")
converter = ODS_VALUE_CONVERTERS.get(cell_odf_type, None)
if converter:
cell = converter(cell)
if cell_odf_type != 'string':
tc.setAttrNS(OFFICENS, cell_odf_value_token, cell)
tc.addElement(P(text=cell))
else:
lines = cell.split('\n')
for line in lines:
tc.addElement(P(text=line))
row.addElement(tc)
示例4: write_cell
# 需要导入模块: from odf.table import TableCell [as 别名]
# 或者: from odf.table.TableCell import setAttrNS [as 别名]
def write_cell(self, row, cell):
"""write a native cell"""
cell_to_be_written = TableCell()
cell_type = type(cell)
cell_odf_type = converter.ODS_WRITE_FORMAT_COVERSION.get(
cell_type, "string")
cell_to_be_written.setAttrNS(OFFICENS, "value-type", cell_odf_type)
cell_odf_value_token = converter.VALUE_TOKEN.get(
cell_odf_type, "value")
converter_func = converter.ODS_VALUE_CONVERTERS.get(
cell_odf_type, None)
if converter_func:
cell = converter_func(cell)
if cell_odf_type != 'string':
cell_to_be_written.setAttrNS(OFFICENS, cell_odf_value_token, cell)
cell_to_be_written.addElement(P(text=cell))
else:
lines = cell.split('\n')
for line in lines:
cell_to_be_written.addElement(P(text=line))
row.addElement(cell_to_be_written)
示例5: _get_cell
# 需要导入模块: from odf.table import TableCell [as 别名]
# 或者: from odf.table.TableCell import setAttrNS [as 别名]
def _get_cell(self, label, stylename=None):
"""
Build a TableCell and adapt the format to the provided label format
:param label: The data to write (int/float/bool/date/str/unicode)
:param str stylename: One of the stylenames added in the __init__
:returns: A TableCell instance
"""
if stylename is not None:
cell_to_be_written = TableCell(stylename=stylename)
else:
cell_to_be_written = TableCell()
cell_type = type(label)
cell_odf_type = converter.ODS_WRITE_FORMAT_COVERSION.get(
cell_type,
"string"
)
cell_to_be_written.setAttrNS(OFFICENS, "value-type", cell_odf_type)
cell_odf_value_token = converter.VALUE_TOKEN.get(
cell_odf_type,
"value",
)
converter_func = converter.ODS_VALUE_CONVERTERS.get(
cell_odf_type,
None
)
if converter_func:
label = converter_func(label)
if cell_odf_type != 'string':
cell_to_be_written.setAttrNS(OFFICENS, cell_odf_value_token, label)
cell_to_be_written.addElement(P(text=label))
else:
lines = label.split('\n')
for line in lines:
cell_to_be_written.addElement(P(text=line))
return cell_to_be_written