aktuell versuche ich mich an openpyxl.
Mein Ziel: Ich möchte gerne meiner Excel Tabelle einen Linearen Chart hinzufügen.
Mein Code:
Code: Alles auswählen
import openpyxl as xl
from openpyxl.chart import LineChart, Reference
def addchart(filename):
wb = xl.load_workbook(filename)
sheet = wb["Tabelle1"]
c1 = LineChart()
c1.title = "Übersicht"
c1.style = 13
c1.y_axis.title = "Kurs"
c1.x_axis.title = "Datum"
data = Reference(self.sheet, min_col = 2, min_row = 1, max_col = 5, max_row = 19)
c1.add_data(data)
sheet.add_chart(c1, "F3")
wb.save("Kurse.xlsx")
addchart("Kurse.xlsx")
Traceback (most recent call last):
File "eifuegenchart.py", line 22, in <module>
addchart("Kurse.xlsx")
File "eifuegenchart.py", line 8, in addchart
wb = xl.load_workbook(filename)
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\reader\excel.py", line 312, in load_workbook
reader.read()
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\reader\excel.py", line 268, in read
self.read_manifest()
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\reader\excel.py", line 136, in read_manifest
src = self.archive.read(ARC_CONTENT_TYPES)
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\zipfile.py", line 1428, in read
with self.open(name, "r", pwd) as fp:
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\zipfile.py", line 1467, in open
zinfo = self.getinfo(name)
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\zipfile.py", line 1395, in getinfo
'There is no item named %r in the archive' % name)
KeyError: "There is no item named '[Content_Types].xml' in the archive"
Lösungsvorschläge wären super! Vielen Dank!