2016-07-18 7 views
0

はXLSファイルに書き込むためのガイドを追って、使用exmapleは従っていました:xlwtは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

これは本当に愚かな質問も(しかしとしてもガイドはこれを「有効」と表示します。

答えて

2

write()メソッドの最初の2つの引数は、文字列ではなく行番号と列番号でなければなりません。

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

FYI、ここ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. 

    ... 
+0

ありがとうございました!私は非常に非常に愚かな感じ、今(私はその前に試み、それが失敗した誓います) –

関連する問題