例子文件如下: 一些复杂的读取操作getCells.py import openpyxl wb = openpyxl.load_workbook('example.xlsx') sheet = wb.get_sheet_by_name('Sheet1') print(sheet.cell(row=1, column=2).value) # from 1 to 8 step is 2 for i in range(1, sheet.max_row + 1, 2): print(i, sheet.c…
源数据如图: 宏操作: 生成数据后: 关键操作:在excel中启用开发工具,添加宏,然后添加模块即可,编辑完代码后,自定义功能按钮即可. Sub MakeDataSource() Dim isExistDestinationSheet isExistDestinationSheet = False Dim i For i = 1 To Sheets.Count If Sheets(i).Name = "b" Then isExistDestinationSheet = True End…