當前位置: 首頁>>代碼示例>>Python>>正文


Python TableCell.setAttrNS方法代碼示例

本文整理匯總了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)
開發者ID:CroissanceCommune,項目名稱:autonomie,代碼行數:9,代碼來源:ods.py

示例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)
開發者ID:fuhrysteve,項目名稱:pyexcel-ods,代碼行數:15,代碼來源:__init__.py

示例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)
開發者ID:targueriano,項目名稱:neuroIFC,代碼行數:19,代碼來源:__init__.py

示例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)
開發者ID:schulzsebastian,項目名稱:qgisplugin_spreadsheet,代碼行數:23,代碼來源:ods.py

示例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
開發者ID:CroissanceCommune,項目名稱:autonomie,代碼行數:38,代碼來源:ods.py


注:本文中的odf.table.TableCell.setAttrNS方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。