如何向许多Excel单元格添加数据

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

我将从数据库中检索信息并将表放入表中,如下所示

enter image description here

这里我正在合并单元格,但是我无法添加数据,因为它给我一个错误

Traceback (most recent call last):
  File "main.py", line 37, in <module>
    for name, score in (scores):
ValueError: too many values to unpack (expected 2)

scores = (
    ['ankit', 1000, 1264, 4125],
    ['rahul',   100, 1452, 4578],
    ['priya',  300, 123, 1452],
    ['harshita',    50, 412,458],
)

row = 12
col = 0

# Iterate over the data and write it out row by row.
for name, score in (scores):
    worksheet.write(row, col, name)
    worksheet.write(row, col + 1, score)
    row += 1

我将添加上面的代码所示的内容,但我不能,此处,ID单元格应根据数据长度自动填充数字顺序。请谁能帮助我解决这些问题?这需要很多时间。请。提前致谢!

python excel python-3.x xlsxwriter
1个回答
0
投票

不确定为什么要为得分条目添加列表元组,从中读取条目的方式不正确。

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