我在 openpyxl 中遇到此错误 TypeError: Table.init() 得到了意外的关键字参数“displayName”
我已经检查了文档中的所有内容,它看起来与我的代码中的完全相同。 Openpyxl 文档
我#ve尝试删除displayName,然后错误更改为ref关键字。
from openpyxl import Workbook
from openpyxl.worksheet.table import Table, TableStyleInfo
from reportlab import Table
#........ data is a list like in the example
# Create a Workbook instance
wb = Workbook()
# Create sheets
ws_source = wb.active
# Append data to the first sheet
for row_data in data:
ws_source.append(row_data)
ws_source.title = "Source Sample List"
# Create a table with the data
table_range = "A1:I" + str(len(data))
tab = Table(displayName="SourceSampleTable", ref=table_range)
tab.tableStyleInfo = TableStyleInfo(
name="TableStyleMedium9", showFirstColumn=False, showLastColumn=False, showRowStripes=True, showColumnStripes=True
)
ws_source.add_table(tab) # Add the table to the sheet
好的reportlab也有表格。所以这是简单的冲突。