Skip to content

Instantly share code, notes, and snippets.

@fornext1119
Created April 11, 2012 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fornext1119/2359450 to your computer and use it in GitHub Desktop.
Save fornext1119/2359450 to your computer and use it in GitHub Desktop.
Python で Excel のシート名一覧を出力
# coding: cp932
import win32api, win32con, win32com, win32com.client, os, time, sys
excelApp = win32com.client.Dispatch("Excel.Application")
excelApp.Visible = True
excelApp.DisplayAlerts = False #警告メッセージをOFF
#ブックを読み取り専用で開く
book = excelApp.workbooks.open(sys.argv[1], False, True)
for sheet in book.Worksheets:
print sheet.name
book.Close()
excelApp.Quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment