您当前的位置: 首页 >  Python

Dream丶Killer

暂无认证

  • 0浏览

    0关注

    188博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Python读写Excel文件

Dream丶Killer 发布时间:2021-02-20 20:33:37 ,浏览量:0

读取

Excel 02.xlsx文件内容如下 在这里插入图片描述

import xlwings as xw

app = xw.App(visible=True, add_book=False)
app.display_alerts = False
app.screen_updating = False
wb = app.books.open(r'C:\Users\pc\Desktop\数据分析\Excel 练习课件\Excel 02.xlsx')
data = app.books[0].sheets[0].range('A3:G20').value
print(data)
wb.close()
app.quit()

在这里插入图片描述

写入

import xlwings as xw

wb = xw.Book()
sht = wb.sheets[0]
info_list = [['01', '已揽收', 'beijing'],
             ['02', '已发货', 'shanghai'],
             ['03', '已揽收', 'tianjin'],
             ['04', '已发货', 'chengdu'],
             ['05', '正在派送', 'chongqing']]
titles = [['货号', '状态', '地点']]
sht.range('A1').value = titles
sht.range('A2').value = info_list
wb.save(r'C:\Users\pc\Desktop\test.xlsx')

test.xlsx文件内容 在这里插入图片描述

关注
打赏
1655344294
查看更多评论
立即登录/注册

微信扫码登录

2.3861s