python - 将数据附加到openpyxl中的现有表
问题描述
我正在尝试使用 openpyxl 将一些数据附加到 Excel 电子表格中的现有表中
我在文档中能找到的只是如何创建一个新表,而不是如何向它们添加数据
对此的任何帮助或解决方法将不胜感激,谢谢
解决方案
您可以遍历工作表_tables。假设您的表名为SalesTable,并且您希望将表范围编辑为 A1:C10。设置table.ref
为“A1:C10”
for table in worksheet._tables:
if table.displayName == "SalesTable":
table.ref = "A1:C10"
随着较新版本的 OpenPyXL_tables
已更改为.tables
for table in worksheet.tables:
if table.displayName == "SalesTable":
table.ref = "A1:C10"
推荐阅读
- azure-active-directory - 如果使用 msal.js,在登录过程中会丢失“让我登录”消息
- ssh - ssh克隆不适用于Windows bash(客户端)的gitlab服务器
- r - 表计数值加倍
- sql - 如何在列值之前添加@符号并用','分隔?
- azure - 如何在 Azure 订阅中启用对图库图像的编程访问?
- vue.js - 如何使用Vue实现“最近访问”?
- c++ - 如何将 cv::mat 对象从 python 模块传递给 c++ 函数并返回返回的 cv::mat 类型的对象?
- typescript - 类型保护泛型并将其定义为可选
- javascript - 使用 rxjs 纠正状态不变性
- javascript - JSON字符串到类匹配在asp.net核心中不起作用