本文整理汇总了Python中openpyxl.writer.charts.ChartWriter.write_rels方法的典型用法代码示例。如果您正苦于以下问题:Python ChartWriter.write_rels方法的具体用法?Python ChartWriter.write_rels怎么用?Python ChartWriter.write_rels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openpyxl.writer.charts.ChartWriter
的用法示例。
在下文中一共展示了ChartWriter.write_rels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _write_worksheets
# 需要导入模块: from openpyxl.writer.charts import ChartWriter [as 别名]
# 或者: from openpyxl.writer.charts.ChartWriter import write_rels [as 别名]
def _write_worksheets(self, archive):
drawing_id = 1
chart_id = 1
image_id = 1
shape_id = 1
comments_id = 1
for i, sheet in enumerate(self.workbook.worksheets):
archive.writestr(PACKAGE_WORKSHEETS + '/sheet%d.xml' % (i + 1),
write_worksheet(sheet, self.workbook.shared_strings,
))
if (sheet._charts or sheet._images
or sheet.relationships
or sheet._comment_count > 0):
rels = write_rels(sheet, drawing_id, comments_id)
archive.writestr(
PACKAGE_WORKSHEETS + '/_rels/sheet%d.xml.rels' % (i + 1),
tostring(rels)
)
if sheet._charts or sheet._images:
dw = DrawingWriter(sheet)
archive.writestr(PACKAGE_DRAWINGS + '/drawing%d.xml' % drawing_id,
dw.write())
archive.writestr(PACKAGE_DRAWINGS + '/_rels/drawing%d.xml.rels' % drawing_id,
dw.write_rels(chart_id, image_id)) # TODO remove this dependency
drawing_id += 1
for chart in sheet._charts:
cw = ChartWriter(chart)
archive.writestr(PACKAGE_CHARTS + '/chart%d.xml' % chart_id,
cw.write())
if chart._shapes:
archive.writestr(PACKAGE_CHARTS + '/_rels/chart%d.xml.rels' % chart_id,
cw.write_rels(drawing_id)) # TODO remove this dependency
sw = ShapeWriter(chart._shapes)
archive.writestr(PACKAGE_DRAWINGS + '/drawing%d.xml' % drawing_id,
sw.write(shape_id)) # TODO remove this dependency
shape_id += len(chart._shapes)
drawing_id += 1
chart_id += 1
image_id = self._write_images(sheet._images, archive, image_id)
if sheet._comment_count > 0:
cw = CommentWriter(sheet)
archive.writestr(PACKAGE_XL + '/comments%d.xml' % comments_id,
cw.write_comments())
archive.writestr(PACKAGE_XL + '/drawings/commentsDrawing%d.vml' % comments_id,
cw.write_comments_vml())
comments_id += 1
示例2: _write_worksheets
# 需要导入模块: from openpyxl.writer.charts import ChartWriter [as 别名]
# 或者: from openpyxl.writer.charts.ChartWriter import write_rels [as 别名]
def _write_worksheets(self, archive, shared_string_table, style_writer):
drawing_id = 1
chart_id = 1
image_id = 1
shape_id = 1
for i, sheet in enumerate(self.workbook.worksheets):
archive.writestr(
PACKAGE_WORKSHEETS + "/sheet%d.xml" % (i + 1),
write_worksheet(sheet, shared_string_table, style_writer.get_style_by_hash()),
)
if sheet._charts or sheet._images or sheet.relationships:
archive.writestr(
PACKAGE_WORKSHEETS + "/_rels/sheet%d.xml.rels" % (i + 1), write_worksheet_rels(sheet, drawing_id)
)
if sheet._charts or sheet._images:
dw = DrawingWriter(sheet)
archive.writestr(PACKAGE_DRAWINGS + "/drawing%d.xml" % drawing_id, dw.write())
archive.writestr(
PACKAGE_DRAWINGS + "/_rels/drawing%d.xml.rels" % drawing_id, dw.write_rels(chart_id, image_id)
)
drawing_id += 1
for chart in sheet._charts:
cw = ChartWriter(chart)
archive.writestr(PACKAGE_CHARTS + "/chart%d.xml" % chart_id, cw.write())
if chart._shapes:
archive.writestr(
PACKAGE_CHARTS + "/_rels/chart%d.xml.rels" % chart_id, cw.write_rels(drawing_id)
)
sw = ShapeWriter(chart._shapes)
archive.writestr(PACKAGE_DRAWINGS + "/drawing%d.xml" % drawing_id, sw.write(shape_id))
shape_id += len(chart._shapes)
drawing_id += 1
chart_id += 1
for img in sheet._images:
buf = StringIO()
img.image.save(buf, format="PNG")
archive.writestr(PACKAGE_IMAGES + "/image%d.png" % image_id, buf.getvalue())
image_id += 1
示例3: _write_worksheets
# 需要导入模块: from openpyxl.writer.charts import ChartWriter [as 别名]
# 或者: from openpyxl.writer.charts.ChartWriter import write_rels [as 别名]
def _write_worksheets(self, archive, shared_string_table, style_writer):
drawing_id = 1
chart_id = 1
shape_id = 1
for i, sheet in enumerate(self.workbook.worksheets):
archive.writestr(PACKAGE_WORKSHEETS + '/sheet%d.xml' % (i + 1),
write_worksheet(sheet, shared_string_table,
style_writer.get_style_by_hash()))
if sheet._charts or sheet.relationships:
archive.writestr(PACKAGE_WORKSHEETS +
'/_rels/sheet%d.xml.rels' % (i + 1),
write_worksheet_rels(sheet, drawing_id))
if sheet._charts:
dw = DrawingWriter(sheet)
archive.writestr(PACKAGE_DRAWINGS + '/drawing%d.xml' % drawing_id,
dw.write())
archive.writestr(PACKAGE_DRAWINGS + '/_rels/drawing%d.xml.rels' % drawing_id,
dw.write_rels(chart_id))
drawing_id += 1
for chart in sheet._charts:
cw = ChartWriter(chart)
archive.writestr(PACKAGE_CHARTS + '/chart%d.xml' % chart_id,
cw.write())
if chart._shapes:
archive.writestr(PACKAGE_CHARTS + '/_rels/chart%d.xml.rels' % chart_id,
cw.write_rels(drawing_id))
sw = ShapeWriter(chart._shapes)
archive.writestr(PACKAGE_DRAWINGS + '/drawing%d.xml' % drawing_id,
sw.write(shape_id))
shape_id += len(chart._shapes)
drawing_id += 1
chart_id += 1