python通过openpyxl控制excel简单记录
#设置边框样式
from openpyxl.styles import Border, borders, colors, Side
side = Side(border_style='medium',color=colors.BLACK)
border = Border(left=side,right=side,top=side,bottom=side)
cell = sheet.cell(row = 1,column = 1)
cell.border = border
https://www.cnblogs.com/shanger/p/13176063.html里展示了各种样式
#插入图片
from openpyxl.drawing.image import Image
img = Image(image_dir)
sheet.add_image(img,'A8')
img.width, img.height = (233,666)#改变图片大小
#合并单元格
sheet.merge_cells(start_row=15, start_column=2,
end_row=15, end_column=4)
#改变单元格大小
sheet.column_dimensions['A'].width = 22
sheet.row_dimensions[1].height = 18
#填入内容
cell = sheet.cell(row = 2,column = 2)
cell.value = value
#创建与保存
wb=load_workbook('./init/test.xlsx')
pass
wb.save(report_dir)