excel - Want to read Worksheets from a workbook using Python Wincom32 -


i want read worksheets workbook using python wincom32 module not able read if number of sheets more. example have excel workbook total 150 worksheets in , trying read 89th excel worksheet using python wincom32 module giving me sheet name not present in excel workbook @ all. using below python code

import win32com.client dispatch = win32com.client.dispatch excel = dispatch("excel.application") excel.visible = 1 wb = excel.workbooks.open('<path excel>') count = wb.sheets.count # count stores total number of worksheets present print count   ws_name = wb.sheets[ 89 ].name  """ supposed read name of 89th worksheet instead giving me garbage     name  """ print ws_name 

there mistakes in code:
1) instead excel.visible = 1 should excel.visible = 1,
2) instead excel.workbooks.open('<path excel>') - excel.workbooks.open('<path excel>')
3) instead wb.sheets.count - wb.sheets.count,
4) instead wb.sheets[ 89 ].name - wb.sheets[ 89 ].name

this fixed version (works me):

import win32com.client dispatch = win32com.client.dispatch excel = dispatch("excel.application") excel.visible = 1 wb = excel.workbooks.open('<path excel>) count = wb.sheets.count # count stores total number of worksheets present print count ws_name = wb.sheets[ 89 ].name """ supposed read name of 89th worksheet instead giving me garbage     name  """ print ws_name 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -