Sep-23-2019, 02:03 AM
I need to make a subclass of ScatterChart from the openpyxl module. When the chart is created directly from "openpyxl.chart.ScatterChart()", it works as expected. However, it's subclass won't load properly in Excel (2010), it is ignored and shows this error:
Error:Removed Part: /xl/drawings/drawing1.xml part. (Drawing shape)
.#!/usr/bin/python3 import os import openpyxl LOCAL = os.getcwd() class Sheet(openpyxl.Workbook): def __init__(self): super().__init__() class Chart(openpyxl.chart.ScatterChart): def __init__(self): super().__init__() #################################### # This work chart = openpyxl.chart.ScatterChart() # This doesn't chart = Chart() #################################### sheet = Sheet() sheet.active.add_chart(chart) sheet.save(f"{LOCAL}/file.xlsx")The content of "/xl/drawings/drawing1.xml" remain the same in both cases.
Quote:<wsDr xmlns="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"><oneCellAnchor><from><col>4</col><colOff>0</colOff><row>14</row><rowOff>0</rowOff></from><ext cx="5400000" cy="2700000"/><graphicFrame><nvGraphicFramePr><cNvPr id="1" name="Chart 1"/><cNvGraphicFramePr/></nvGraphicFramePr><xfrm/><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId1"/></a:graphicData></a:graphic></graphicFrame><clientData/></oneCellAnchor></wsDr>