Search code examples
pythonexcelbeautifulsoupxlwtopenpyxl

Writing Excel file specifying Row and Column number - openpyxl


I have a code which had written with XLWT library and now I am switching to openpyxl because it allows XLSX files that has more Row limit than XLWT allows

I wrote the cells by specifying the row and column number in XLWT

worksheet.write(1, 2, "City")

Now I want to know how can I do this in openpyxl??? I have tried

worksheet.cell(1, 1).value = "test"

But I am getting an error

AttributeError: 'int' object has no attribute 'replace'

Solution

  • It should be:

    worksheet.cell(row=1, column=1).value = "test"