按照指南写入xls文件,使用的例子如下:
wb = xlwt.Workbook()
newsheet=wb.add_sheet('sheet1')
newsheet.write('0','0','testing')
wb.save(testing.xls)
但是我收到错误说:
ValueError:行索引为“0”,不允许使用.xls格式
这可能是一个非常愚蠢的问题(但是由于指南显示这是“有效”,有没有人知道这导致了什么?
答案 0 :(得分:2)
write()
方法的前两个参数必须是行号和列号,而不是字符串:
newsheet.write(0, 0, 'testing')
仅供参考,这是write()
method docstring:
def write(self, r, c, label="", style=Style.default_style):
"""
This method is used to write a cell to a :class:`Worksheet`.
:param r:
The zero-relative number of the row in the worksheet to which
the cell should be written.
:param c:
The zero-relative number of the column in the worksheet to which
the cell should be written.
...