共计 450 个字符,预计需要花费 2 分钟才能阅读完成。
1、获取sheet直接使用数组形式:
sheet = work_book['Sheet0']
2、取单元格值是value
some_value = sheet.cell(row=1, column=1).value
3、遍历行 列的方法
# 这个的索引是从1开始的,最后max+1是为了最后一行可以匹配到
# 遍历行
for row in range(begin_row_index, sheet.max_row + 1):
# some code
break
# 遍历列
# 遍历行
for column in range(begin_column_index, sheet.max_column + 1):
# some code
break
4、填充,字体等设置方法
# 设置颜色 具体函数内容请阅读文档
sheet.cell(row=1, column=1).font = Font(color='FF0000')
# 设置填充
sheet.cell(row=1, column=1).fill = PatternFill(patternType='solid', fgColor='FF0000')
正文完