Openpyxl TypeError:Table.__init__() 获得意外的关键字参数“displayName”

问题描述 投票:0回答:1

我在 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

python openpyxl reportlab
1个回答
-1
投票

好的reportlab也有表格。所以这是简单的冲突。

© www.soinside.com 2019 - 2024. All rights reserved.