import openpyxl #劉任昌輸入import openpyxl處理EXCEL的函式庫
book = openpyxl.load_workbook(r'wb.xlsx') #開啟EXCEL工作簿wb.xlsx
print("1. 列出所有工作表名稱")
sheetNames=book.sheetnames #所有工作表的集合
for name in sheetNames:
print(name)
print("2. 針對特定工作表, 列出前面數列")
#sheet = book["python"]
#for row in sheet.iter_rows(min_row=1, max_row=3, min_col=1, max_col=5, values_only=True):
# print(row)
print("3. 列出工作表所有內容")
#sheet["F1"], sheet["G1"], sheet["H1"], sheet["I1"]="波段H","波段L","部位","損益"
#sheet["F2"], sheet["G2"], sheet["H2"], sheet["I2"]=sheet["C2"].value, sheet["D2"].value, 0, 0
#for row in sheet.iter_rows(min_row=1, max_row=3, min_col=1, max_col=9, values_only=True):
# print(row)
#book.save()
留言
張貼留言