本文整理汇总了Python中openpyxl.xml.functions.Element.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Element.remove方法的具体用法?Python Element.remove怎么用?Python Element.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openpyxl.xml.functions.Element
的用法示例。
在下文中一共展示了Element.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write
# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import remove [as 别名]
def write(self, root):
# Remove any existing comment shapes
if not hasattr(root, "findall"):
root = Element("xml")
comments = root.findall("{%s}shape" % vmlns)
for c in comments:
if c.get("type") == '#_x0000_t202':
root.remove(c)
# check whether comments shape type already exists
shape_types = root.findall("{%s}shapetype" % vmlns)
comments_type = False
for s in shape_types:
if s.get("id") == '_x0000_t202':
comments_type = True
break
if not comments_type:
self.add_comment_shapetype(root)
for idx, (coord, comment) in enumerate(self.comments, 1026):
self.add_comment_shape(root, idx, coord)
return tostring(root)
示例2: write
# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import remove [as 别名]
def write(self, root):
if not hasattr(root, "findall"):
root = Element("xml")
# Remove any existing comment shapes
comments = root.findall("{%s}shape[@type='#_x0000_t202']" % vmlns)
for c in comments:
root.remove(c)
# check whether comments shape type already exists
shape_types = root.find("{%s}shapetype[@id='_x0000_t202']" % vmlns)
if not shape_types:
self.add_comment_shapetype(root)
for idx, (coord, comment) in enumerate(self.comments, 1026):
self.add_comment_shape(root, idx, coord, comment.height, comment.width)
return tostring(root)