0

I have been trying to write a program that runs a SQL query then takes the data from that SQL query updates an existing Excel sheet while keeping/updating a chart in Python.

Is this possible? I haven't been able to find any existing questions regarding this so I am sorry if this is a repeat.

** For example, I have an items table with three items of varying quantities. I can get the items to appear in my Excel sheet -- but any graph/chart I make is discarded once new information is updated.

Ann
  • 1
  • 2

1 Answers1

0

If you look into this python package https://xlsxwriter.readthedocs.io/

You'll find ways to generate charts from python in your excel file.

Other possibility is to have your data go into a table in excel (not a range but an actual table)

you can follow the logic in this post for more information on how to achieve this Manipulate existing excel table using openpyxl

Henrik Poulsen
  • 935
  • 2
  • 13
  • 32
  • Oh thank you! I was using pandas and couldn't get what I needed to work. – Ann Mar 17 '20 at 04:26
  • Ahh, i believe that Pandas to_excel function overwrites the existing excel sheet with a new sheet, so that would explain your situation. – Henrik Poulsen Mar 17 '20 at 11:51