Python Excel 多sheet 多条数据 自定义写入
来源:互联网 发布:最新骂人网络流行语 编辑:程序博客网 时间:2024/06/05 05:49
pip install xlwt
python excel 数据写入操作,处理网站数据导出以及不是太多数据的爬虫存储, 用处蛮多的轮子。
(150+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=)
1 #coding: utf-8 2 import xlwt 3 from xlwt import Workbook 4 5 6 wb = Workbook() 7 ws = wb.add_sheet('Product') 8 ws_1 = wb.add_sheet('Other') 9 10 fontSize = xlwt.easyxf('font:height 200, name Calibri; align: horiz center;') #字体自定义11 12 row0 = [u'名目',u'链接',u'备注']13 row1 = [u'name',u'file',u'url']14 15 def title_write(row,ws):16 #生成标题17 for i in range(0,len(row)):18 col = ws.col(i)19 col.width=256*1820 if i == (len(row)-1):21 ws.col(i).width = 256*2322 ws.write(0,i,row[i],xlwt.easyxf('font:height 200, name Arial_Unicode_MS, colour_index black, bold on;align: horiz center;'))23 24 title_write(row0,ws)25 title_write(row1,ws_1)26 27 data = [{'1':[u'福尔摩斯探案集',u'http://www.fuermositanan.com/',u'推理'],'2':[u'The Sherlock Holmes stories',u'Arthur Conan Doyle',u'https://ebooks.adelaide.edu.au/d/doyle/arthur_conan/']}]#这里演示写死了,根据实际需求更改28 29 x = 130 for i in data:31 rows_0 = i['1']32 rows_1 = i['2']33 def rows_write(content,ws):34 #生成内容35 for num,rows in enumerate(content):36 rows if rows != None else ''37 ws.write(x, num, rows, fontSize)38 rows_write(rows_0,ws)39 rows_write(rows_1,ws_1)40 x += 141 42 fname='Books.xls'43 wb.save(fname)
阅读全文
0 0
- Python Excel 多sheet 多条数据 自定义写入
- python 多sheet页写入excel并发邮件
- java实现从数据库读取数据写入excel,写入多个sheet,6万数据耗时100秒附近
- 【python 写入数据到excel】自定义写入数据到excel顺序 排列
- 导出数据到excel多个sheet
- python数据写入excel表格
- python 将数据写入excel
- c#导出excel支持多sheet导出,可自定义sheetName
- 导出DataSet数据到excel的多个sheet
- (JXL)JAVA读取Excel数据(包含多个Sheet)
- POI导出数据到Excel的多个Sheet
- 请问: vba, excel中打开多个xls文件, 搜索字符串,写入另一个sheet的问题
- python excel sheet复制
- 用python将excel数据写入mysql
- python写入已存在的excel数据
- Python中向excel中写入数据
- Python向excel中写入数据
- ireport excel 多个sheet
- yarn与npm的命令行小结
- 504. Base 7
- Spring data jpa 介绍
- echarts中柱状图数字加千位符
- 求逆序对数
- Python Excel 多sheet 多条数据 自定义写入
- 安全自主可控正迎来行业大爆发,国产操作系统迎来最好时代
- 高德地图开发之基本控件
- plt.fill()
- 高并发网站解决方法
- leetcode292. Nim Game
- session与application生命周期的区别
- 类、对象、属性、方法
- git使用和常见问题处理