openyxl reading existing file - missing charts

79 views
Skip to first unread message

CM

unread,
Feb 4, 2021, 11:20:48 AM2/4/21
to openpyxl-users
Hi,

I have made an xlsx file with data in A1,A2,B1,B2 and then make a Column chart (tried clustered column and stacked column).

When I open then save that template. The data shows in A1,A2,B1,B2 but the graph is not visible.

Literally my code is:

#!/usr/bin/python3
from openpyxl.chart import BarChart, Series, Reference
from openpyxl import load_workbook


wb = load_workbook('/tmp/excel.xlsx')
wb.save("/tmp/new.xlsx")


I copied the example from:

and it makes the charts fine, but that's making a new one rather than rendering an existing one. 

Can anyone suggest why the graph is not rendering? 

Charlie Clark

unread,
Feb 5, 2021, 8:20:55 AM2/5/21
to openpyxl-users
You mean that a chart in your template file is no longer visible after
you process this with openpyxl? It's unusual if there is also no
exception but without the file it's not possible to say.

Charlie

--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226

CM

unread,
Feb 5, 2021, 8:41:09 AM2/5/21
to openpyxl-users
Thanks Charlie

See attached the template file I am using (excel.xlsx) and also the file that openpyxl gives me once I save it.
excel.xlsx
output from openpyxl.xlsx
Reply all
Reply to author
Forward
0 new messages