xlwt 无法写入 xls 文件?

xlwt can't write to xls file?

一直在遵循写入 xls 文件的指南,使用的示例如下:

wb = xlwt.Workbook()
newsheet=wb.add_sheet('sheet1')
newsheet.write('0','0','testing')
wb.save(testing.xls)

但是我收到一条错误消息:

ValueError: row index was '0', not allowed by .xls format

这可能是一个非常愚蠢的问题(但正如指南所示"valid"有谁知道是什么原因造成的?

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.

     ...