Adrocks__
Adrocks__

Reputation: 29

xlwt can't write to xls file?

Been following a guide to write to xls files and the exmaple used was the following:

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

However I get an error saying:

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

This may be a really stupid question (but as guides show this as "valid" does anyone know whats causing this?

Upvotes: 0

Views: 1128

Answers (1)

alecxe
alecxe

Reputation: 473753

The first two arguments of the write() method have to be row and column numbers, not strings:

newsheet.write(0, 0, 'testing')

FYI, here is the 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.

     ...

Upvotes: 3

Related Questions