python读取excel多个sheet页并合并成一页
生活随笔
收集整理的這篇文章主要介紹了
python读取excel多个sheet页并合并成一页
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
python讀取excel多個sheet頁并合并成一頁
import xlrd import xlwtdata = xlrd.open_workbook("database.xlsx")workbook = xlwt.Workbook() worksheet = workbook.add_sheet('sheets2one') '''sheet頁'''page0 = len(data.sheets()) #讀取表格中的頁數print(f'該表格文件有 {page0} 頁') aim_hang = 0for ye in range(page0):table0 = data.sheets()[ye]nrow0 = table0.nrows #行nclow0 = table0.ncols #列print(nclow0)print(nrow0)for hang in range(nrow0):for lie in range(nclow0):aim_data = int(table0.cell_value(hang, lie))worksheet.write(aim_hang , lie , str(aim_data))print(aim_data)aim_hang = aim_hang + 1aim_hang = aim_hang + 2workbook.save('Excel_test.xls')總結
以上是生活随笔為你收集整理的python读取excel多个sheet页并合并成一页的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DM常用命令
- 下一篇: 【学习】笔记本电脑重新安装系统win10