컴퓨터/Python

win32com ColorIndex 칼라인덱스

풍경소리^^ 2019. 6. 11. 23:42
import win32com.client

# explore=win32com.client.Dispatch("InternetExplorer.Application")
# explore.Navigate ( "http://www.google.com")
# explore.Visible=True

# word=win32com.client.Dispatch("Word.Application")
# word.Visible=True


# Excel = win32com.client.Dispatch("Excel.Application")
# Excel.Visible = True
#
# wb = Excel.Workbooks.Add()
# ws = wb.Worksheets("Sheet1")
# ws.Cells(1,1).Value = "Hello"
# ws.Cells(1,2).Value = "This is Gus World!"
# ws.Cells(1,2).Interior.ColorIndex = 45;
#
# wb.SaveAs("d:\git\python\win32com\ex.xlsx")
# Excel.Application.Quit()

excel=win32com.client.Dispatch("Excel.Application")
excel.Visible=True
# wb=excel.Workbooks.Open('d:\git\python\win32com\ex.xlsx')
wb = excel.Workbooks.Add()
ws = wb.Worksheets("Sheet1")
ws=wb.ActiveSheet
k=0
ws.Cells(1,1).Value="ColorIndex칼라인덱스"
ws.Cells(1,10).Value=0
ws.Cells(1,1).Interior.ColorIndex=0
for i in range(1,7):
for j in range(1,11):
k+=1
if k>56:
break
ws.Cells(i+1,j).Value=k
ws.Cells(i + 1, j).Interior.ColorIndex=k


# print(ws.Cells(1,2).Value)
wb.SaveAs("d:\git\python\win32com\ex.xlsx")
excel.Quit()