将数据附加到 openpyxl 中的现有表
Appending data to existing tables in openpyxl
我正在尝试使用 openpyxl
将一些数据附加到 excel 电子表格中的现有 table
我在文档中所能找到的只是如何创建一个新的 table 而不是如何向它们添加数据
如有任何帮助或解决方法,我们将不胜感激
谢谢
您可以遍历工作表 _tables。假设您的 table 名为 SalesTable,并且您想将 tables 范围编辑为 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"
我正在尝试使用 openpyxl
将一些数据附加到 excel 电子表格中的现有 table我在文档中所能找到的只是如何创建一个新的 table 而不是如何向它们添加数据
如有任何帮助或解决方法,我们将不胜感激 谢谢
您可以遍历工作表 _tables。假设您的 table 名为 SalesTable,并且您想将 tables 范围编辑为 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"