仅当未选择除“线性”以外的其他趋势线类型(例如“多边形”,“指数”或“幂”)时,才将趋势线添加到openpyxl折线图中。 这有效:
series = Series(data, title=sheetname)
series.trendline = Trendline(
dispEq=True, dispRSqr=True, trendlineType="linear")
c1.append(series)
这不会,并且无法构建图表:
series = Series(data, title=sheetname)
series.trendline = Trendline(
dispEq=True, dispRSqr=True, trendlineType="poly")
c1.append(series)
尽管如此,文档仍然声称这应该起作用:Doc Link
有人知道为什么会这样吗?
编辑: Python没有失败,但是打开excel文件会导致:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error094400_01.xml</logFileName><summary>Errors were detected in file '...'</summary><removedParts><removedPart>Removed Part: /xl/drawings/drawing1.xml part. (Drawing shape)</removedPart></removedParts></recoveryLog>