1. pip install xlwings
https://zhuanlan.zhihu.com/p/82783751?utm_source=wechat_session&utm_medium=social&utm_oi=1087267078251094016&utm_campaign=shareopn

import xlwings as xw

app=xw.App(visible=True,add_book=False)
# app=xw.App(visible=False,add_book=False)

wb=app.books.add()
sht=wb.sheets['sheet1']

wb.sheets['sheet1'].range('A1').value='FontTest'

wb.sheets['sheet1'].range('B1').value='Overall memory usage'
wb.sheets['sheet1'].range('B1').autofit()
wb.sheets['sheet1'].range('C1').value='Memory usage  by process'
wb.sheets['sheet1'].range('C1').autofit()
wb.sheets['sheet1'].range('D1').value='Flash usage'
wb.sheets['sheet1'].range('D1').autofit()


# font_name = sht.range('A1').api.Font.Name	# 获取字体名称
# font_size = sht.range('A1').api.Font.Size	# 获取字体大小
# bold = sht.range('A1').api.Font.Bold		# 获取是否加粗,True--加粗,False--未加粗
# color = sht.range('A1').api.Font.Color		# 获取字体颜色

# sht.range('A1').api.Font.Name = 'Times New Roman'	# 设置字体为Times New Roman
# sht.range('A1').api.Font.Size = 15			# 设置字号为15
# sht.range('A1').api.Font.Bold = True		# 加粗
sht.range('A1').api.Font.Color = 0x0000ff	# 设置为红色RGB(255,0,0)



# 将列表[1,2,3]储存在B3:D3中
sht.range('B3').value=[1,2,3]

# 将列表[1,2,3]储存在B1:B6中
sht.range('B4').options(transpose=True).value=[1,2,3]

# 将2x2表格,即二维数组,储存在A1:B2中,如第一行1,2,第二行3,4
sht.range('B8').options(expand='table').value=[[1,2],[3,4]]

# 合并但单元格
sht.range('A1:A10').api.merge()

# wb.save(r'test.xlsx')
# wb.close()
# app.quit()