Python 可视化操作Excel表格

使用插件:xlwings (pip install xlwings)

官方文档:https://docs.xlwings.org/en/stable/installation.html

简单操作:

import time
import xlwings as xw

"""
visible
Ture:可见excel
False:不可见excel

add_book
True:打开excel并且新建工作簿
False:不新建工作簿
"""
app = xw.App(visible=True, add_book=False)


wb = app.books.open('./a.xlsx')
wb2 = app.books.open("./b.xlsx")

sht = wb.sheets["sheet1"]
sht2 = wb2.sheets["sheet1"]

sht.range("A1").value = "a.xlsx"
sht2.range("A1").value = "b.xlsx"

# 打印当前活跃的books-<Book [b.xlsx]>
#print(app.books.active)

# 打印当前的book-Books([<Book [a.xlsx]>, <Book [b.xlsx]>])
#print(app.books)

wb.save()
wb2.save()

# 关闭a.xlsx文件-指定操作的excel
# wb.close()
for book in app.books :
    book.close()

sleep(1)
app.quit()
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇