Python添加excel表格的批注
相关链接:https://openpyxl.readthedocs.io/en/stable/index.html
https://blog.csdn.net/weixin_38883338/article/details/98733734
from openpyxl import load_workbook from openpyxl.comments import Comment commonts = """这是批注的内容""" # 注意:openpyxl 模块不支持.xls格式的表格文件,需要重新保存为.xlsx格式的表格才行 def add_excel_comment(): file = "./xxx信息表.xlsx" wb = load_workbook(filename=file) # wb.get_sheet_by_name("xxx开发提供表") print(wb.sheetnames) ws = wb["xxx开发提供表"] # ws = wb.active 当前使用的sheet,一般都是第一页 comment = Comment(commonts, 'author') # 设置批注框的宽,高 comment.width = 800 comment.height = 600 # 在指定的单元格上面设置批注 ws['C16'].comment = comment wb.save('./批注的内容是啥.xlsx')