technical stacks
windows 10
openpyxl
pip install openpyxl
from openpyxl import Workbook
Workbook()
Workbook().active
Workbook().active.title = "sheet 000"
Workbook().save("jhp RPA.xlsx")
Workbook().close()
Workbook().create_sheet("sheet 002",3)
Workbook().create_sheet("sheet 003",4) # create sheet as sheet 003 at index 4
Workbook().create_sheet().title = "sheet 001" # replace sheet title
Workbook().save("jhp RPA.xlsx")
Workbook()["sheet 002"] # dictionary 형태로 sheet에 접근
Workbook()["sheet 002"]["a1"] = "text001"
Workbook()["sheet 002"]["a2"] = "text002"
Workbook()["sheet 002"]["a3"] = "text003"
Workbook()["sheet 002"]["b1"] = "text001"
Workbook()["sheet 002"]["b2"] = "text002"
Workbook()["sheet 002"]["b3"] = "text003"
Workbook().copy_worksheet(Workbook()["sheet 002"]
Workbook().copy_worksheet(Workbook()["sheet 002"].title = "copied sheet"
Workbook().save("jhp RPA.xlsx")
Workbook().sheetnames # show it
Workbook()["sheet 002"]["a1"].value # show it
Workbook()["sheet 002"].cell(row=1, column=1).value # a1
Workbook()["sheet 002"].cell(column=1, row=1).value # a1
Workbook().save("jhp RPA.xlsx")
Workbook()["sheet 002"].cell(column=1, row=1).value = 10
from random import *
for x in range(1,11):
for y in range(1,11):
Workbook()["sheet 002"](row=x, column=y, value=radiant(0,100))
index=0
for x in range(1,11):
for y in range(1,11):
Workbook()["sheet 002"](row=x, column=y, value=index)
index = index + 1
from openpyxl import load_workbook
load_workbook("jhp_RPA002.xlsx").active
for x in range(1,11):
for y in range(1,11):
print(load_workbook.cell(row=x,column=y).value, end=" ") # end 역할 이 뭐지?
print() # 얘가 줄바꿈을 만들어준다.
from openpyxl import load_workbook
load_workbook("jhp_RPA002.xlsx").active
for x in range(1,load_workbook("jhp_RPA002.xlsx").active.max_row + 1):
for y in range(1,load_workbook("jhp_RPA002.xlsx").active.max_column + 1):
print(load_workbook.cell(row=x,column=y).value, end=" ")
print()