#!/usr/bin/env python
from openpyxl import Workbook
from openpyxl.styles import Alignment
book = Workbook()
sheet = book.active
sheet.merge_cells('A1:B2')
cell = sheet.cell(row=1, column=1)
cell.value = 'Sunny day'
cell.alignment = Alignment(horizontal='center', vertical='center')
book.save('merging.xlsx')
实现效果如下;
标签:sheet,openpyxl,单元格,cell,book,--------------------------,import From: https://www.cnblogs.com/cherishthepresent/p/17579087.html