-
-
Save fereria/cfe123d291f08731eb3f to your computer and use it in GitHub Desktop.
Excel Python Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## -*- 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