其他分享
首页 > 其他分享> > 对excel读写的三个模块,xlsxwriter最牛,xlwt , xlrd

对excel读写的三个模块,xlsxwriter最牛,xlwt , xlrd

作者:互联网

1.最牛的模块:xlsxwriter

  
import xlsxwriter
book = xlsxwriter.Workbook("E://a.xlsx") #创建一个文件
workfomat = book.add_format({
'bold': True, #字体加粗
'border':1, #单元格边框宽度
'align': 'center', #对齐方式
'valign': 'vcenter', #字体对齐方式
'fg_color': '#F4B084', #单元格背景颜色
})
sheet = book.add_worksheet("demo1") #添加一个sheet
sheet.insert_image("A1","E://0.png")#插入图片
sheet.write_string("A10","文本",workfomat)#插入文本,参数加入表格样式
sheet.write_row("A2",["1","2"])#插入一行
sheet.write_column("A2",["1","2"])#插入一列
book.close()

标签:xlwt,sheet,workfomat,xlsxwriter,excel,write,插入,book,最牛
来源: https://www.cnblogs.com/wusen0601/p/15489161.html