Skip to content
Advertisement

Python xlsxwriter loop through each worksheet in a workbook

I want to iterate through each worksheet that I have created in a workbook with add_worksheet function. I want to do this with all the available sheets in the workbook and write ‘Hello’ in cell ‘A1’ of each sheet.

Here is the code I am trying:

JavaScript

I was expecting it to write ‘Hello’ in cell ‘A1’ for each available sheet in the workbook.

Getting this error : TypeError: ‘method’ object is not iterable

Advertisement

Answer

You need to remove enumerate and add parenthesis to workbook.worksheets.

Try this :

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement