Skip to content

Instantly share code, notes, and snippets.

@fereria fereria/win32_excel1.py Secret
Created Aug 21, 2015

Embed
What would you like to do?
Excel Python Test
## -*- coding: utf-8 -*-
import win32com.client as win32
#COMを利用して、Excelに接続
xlApp = win32.Dispatch("Excel.Application")e
#Excelを開く
wb = xlApp.Workbooks.Open("E:/testFile.xlsx")
#Sheet取得
#番号またはSheet名
sheet = wb.Worksheets(1)
#Cell取得
cell = sheet.Cells(1,1)
#Cellに数字を入れる
cell.Value = 10
#関数を入れる
sheet.Range("A11").Formula = "=SUM(A1:A10)"
#シート名を変更
sheet.Name = "TEST NAME"
#セーブして閉じる
wb.Save()
wb.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.