简体   繁体   English

从 SQL Server 获取数据并更新现有 Excel 工作表,同时保持表格可能?

[英]Taking data from SQL Server and updating existing Excel sheet while keeping table possible?

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.我一直在尝试编写一个运行 SQL 查询的程序,然后从该 SQL 查询中获取数据更新现有的 Excel 工作表,同时在 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.我可以让这些项目出现在我的 Excel 工作表中——但是一旦新信息更新,我制作的任何图形/图表都会被丢弃。

If you look into this python package https://xlsxwriter.readthedocs.io/如果您查看此 python 包https://xlsxwriter.readthedocs.io/

You'll find ways to generate charts from python in your excel file.您将找到从 excel 文件中的 python 生成图表的方法。

Other possibility is to have your data go into a table in excel (not a range but an actual table)另一种可能性是将您的数据放入 excel 表格中(不是范围而是实际表格)

you can follow the logic in this post for more information on how to achieve this Manipulate existing excel table using openpyxl您可以按照本文中的逻辑获取有关如何使用 openpyxl实现此操作现有 excel 表的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM