用python根据以下要求创建并写入xlsx文档: 第一行,将A1-L1与A2-L2合并居中,写入“粤兴义齿有限公司出货单”,字体要求楷体16号,加下划线; 第二行,将A3与A4合并居中,写入“收货单位:”字体要求宋体10号,将B3-F3与B4-F4合并居中,将G3与G4合并居中,写入"出货日期:"字体要求宋体10号,将H3-I3与H4-I4合并居中,将J3与J4合并居中,写入"NO:",字体要求宋体10号,将K3-L3与K4-L4合并居中; 第三行,将A5-B5合并居中,写入”义齿编号“,字体要求宋体10号加上所有框线,将“总数量”写入C5居中,字体要求宋体10号加上所有框线,将"金额"写入D5居中,字体要求宋体10号加上所有框线,将E5-F5合并居中,写入”牙位“,字体要求宋体10号加上所有框线,将G5-H5合并居中,写入”义齿类型“,字体要求宋体10号加上所有框线,将“数量”写入I5居中,字体要求宋体10号加上所有框线,将“单价”写入J5居中,字体要求宋体10号加上所有框线,将K5-L5合并居中,写入”备注“,字体要求宋体10号加上所有框线;
时间: 2023-04-09 20:02:41 浏览: 109
python调用xlsxwriter创建xlsx的方法
抱歉,我可以回答这个问题。以下是用Python根据要求创建并写入xlsx文档的代码:
```python
import openpyxl
from openpyxl.styles import Font, Alignment, Border, Side
# 创建工作簿
wb = openpyxl.Workbook()
# 创建工作表
ws = wb.active
# 设置字体
font_kai16 = Font(name='楷体', size=16, underline='single')
font_song10 = Font(name='宋体', size=10)
# 设置对齐方式
align_center = Alignment(horizontal='center', vertical='center')
# 设置边框
border_thin = Border(left=Side(style='thin'), right=Side(style='thin'), top=Side(style='thin'), bottom=Side(style='thin'))
# 合并单元格并写入内容
ws.merge_cells('A1:L1')
ws['A1'] = '粤兴义齿有限公司出货单'
ws['A1'].font = font_kai16
ws['A1'].alignment = align_center
ws.merge_cells('A3:A4')
ws['A3'] = '收货单位:'
ws['A3'].font = font_song10
ws['A3'].alignment = align_center
ws.merge_cells('B3:F3')
ws['B3'] = ' '
ws['B3'].border = border_thin
ws['B3'].alignment = align_center
ws.merge_cells('B4:F4')
ws['B4'] = ' '
ws['B4'].border = border_thin
ws['B4'].alignment = align_center
ws.merge_cells('G3:G4')
ws['G3'] = '出货日期:'
ws['G3'].font = font_song10
ws['G3'].alignment = align_center
ws.merge_cells('H3:I3')
ws['H3'] = ' '
ws['H3'].border = border_thin
ws['H3'].alignment = align_center
ws.merge_cells('H4:I4')
ws['H4'] = ' '
ws['H4'].border = border_thin
ws['H4'].alignment = align_center
ws.merge_cells('J3:J4')
ws['J3'] = 'NO:'
ws['J3'].font = font_song10
ws['J3'].alignment = align_center
ws.merge_cells('K3:L3')
ws['K3'] = ' '
ws['K3'].border = border_thin
ws['K3'].alignment = align_center
ws.merge_cells('K4:L4')
ws['K4'] = ' '
ws['K4'].border = border_thin
ws['K4'].alignment = align_center
ws.merge_cells('A5:B5')
ws['A5'] = '义齿编号'
ws['A5'].font = font_song10
ws['A5'].border = border_thin
ws['A5'].alignment = align_center
ws['C5'] = '总数量'
ws['C5'].font = font_song10
ws['C5'].border = border_thin
ws['C5'].alignment = align_center
ws['D5'] = '金额'
ws['D5'].font = font_song10
ws['D5'].border = border_thin
ws['D5'].alignment = align_center
ws.merge_cells('E5:F5')
ws['E5'] = '牙位'
ws['E5'].font = font_song10
ws['E5'].border = border_thin
ws['E5'].alignment = align_center
ws.merge_cells('G5:H5')
ws['G5'] = '义齿类型'
ws['G5'].font = font_song10
ws['G5'].border = border_thin
ws['G5'].alignment = align_center
ws['I5'] = '数量'
ws['I5'].font = font_song10
ws['I5'].border = border_thin
ws['I5'].alignment = align_center
ws['J5'] = '单价'
ws['J5'].font = font_song10
ws['J5'].border = border_thin
ws['J5'].alignment = align_center
ws.merge_cells('K5:L5')
ws['K5'] = '备注'
ws['K5'].font = font_song10
ws['K5'].border = border_thin
ws['K5'].alignment = align_center
# 保存文件
wb.save('出货单.xlsx')
```
阅读全文