使用python读取excel合并成新的excel
2018-03-15 16:39
211 查看
import xlrd import xlwt data1=xlrd.open_workbook('test123.xls') data2= xlrd.open_workbook('test.xls') def mix(data1,data2): f = xlwt.Workbook() sheet1 = f.add_sheet(u'sheet1',cell_overwrite_ok=True) table1 = data1.sheets()[0] table2 = data2.sheets()[0] nrows1 = table1.nrows ncols1 = table1.ncols nrows2 = table2.nrows ncols2 = table2.ncols for i in range(0,nrows1+nrows2): for j in range(0,ncols1): if i<nrows1: sheet1.write(i,j,table1.cell_value(i,j)) else: sheet1.write(i,j,table2.cell_value(i-nrows1,j)) f.save('haha.xls') data=xlrd.open_workbook('haha.xls') return data data=mix(data1,data2)
相关文章推荐
- 使用poi Java封装对Excel内容的读取,支持合并列形式
- Python中使用第三方库xlrd来读取Excel示例
- python使用xlwt读取文件写入Excel
- Delphi中使用python脚本读取Excel数据
- 使用python读取excel
- Python使用xlrd读取Excel格式文件的方法
- Windows下使用Python读取Excel表格数据
- 使用python读取excel
- python读取一个excel多个sheet表并合并
- Python 使用xlrd库读取excel
- 使用Python读取excel数据
- Python 使用 xlrd 读取 Excel格式文件
- 使用python读取.txt文件并保存到Excel中
- Python自动化(三)使用xlrt读取Excel数据
- selenium+python关于登录的脚本代码,使用了读取excel以及向excel中写入测试结果的方法
- python使用xlrd读取excel数据时,整数和日期变小数的解决办法
- python读取excel,使用了pywin32模块
- Python使用pandas读取Excel文件数据和预处理小案例
- selenium+python关于登录的脚本代码,使用了读取excel以及向excel中写入测试结果的方法
- [转] Windows下使用Python读取Excel表格数据