本文整理匯總了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