I import dataframe to an existing excel sheet and graph on that sheet dissappears

30 Views Asked by At

I import dataframe to an excel existing sheet.

   with pd.ExcelWriter('nameofmyexistingexcel.xlsx', mode='a', engine='openpyxl', if_sheet_exists='overlay') as writer:
   mydataframe.to_excel(writer, sheet_name="nameofexistingsheet")

It works correctly. Datframe is imported to excel columns A-K accordingly to dataframe size. Columns B - dates. Excel columns after K (L- T) containts formulas. They are not affected after python reimport, so I can update dataframe as planned.

There are two graphs in excel which takes data from columns A-K and L-T. When I make these graphs via select required columns and create graph, they are not affected after python reimport. When I make some changes in one of this graphs - add axes names, two vertical axes, change colours and markers etc - both of graphs dissappears after python reimport and excel writes warning that is restored excel file and removed unreadable content - graphs.

I did various tests: python reimport removes "complicated" graph even if graph is located on another sheet and isn't related to imported data. Other data on excel sheets aren't affected: dataframes imported correctly, other cells with formulas aren't affected.

Could you please suggest why it happens (for example more complicated graph has has more size/weigh or due to connection) and how to improve it. Thank you

0

There are 0 best solutions below