Python: open excel file
https://github.com/dhellmann/pymotw-3
https://github.com/xlwings/xlwings
https://pypi.org/project/pypiwin32/
https://github.com/Googulator/pypiwin32
https://gist.github.com/gabemarshall/9372073
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import xlwings as xw; from pathlib import Path; import time; # 多文件设置密码 Geovin Du 涂聚文 xlrd、xlwt、xlwings、win32com.client # https://docs.xlwings.org/en/stable/api.html # open(fullname, update_links=None, read_only=None, format=None, password=None, write_res_password=None, ignore_read_only_recommended=None, origin=None, delimiter=None, editable=None, notify=None, converter=None, add_to_mru=None, local=None, corrupt_load=None) app = xw.App(visible = False ,add_book = False ); folder_path = Path( 'C:\\Users\\geovindu\\Documents\\Visual Studio 2017\\Projects\\PythonTickt\\PythonTickt\\excel\\' ); file_list = folder_path.glob( '*.xls*' ); for i in file_list: workbook = app.books. open (i) workbook.api.Password = 'geovindu' workbook.save() workbook.close() app.quit(); print ( 'ok!' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # geovindu 打开文件 #xlrd、xlwt、xlwings、win32com.client(pip install pypiwin32) app = xw.App(visible = False ,add_book = False ); folder_path = Path( 'C:\\Users\\geovindu\\Documents\\Visual Studio 2017\\Projects\\PythonTickt\\PythonTickt\\excel\\14.xlsx' ); workbook = app.books. open (folder_path); #xlwb = xlApp.Workbooks.Open(filename, False, True, None, password) worksheet = workbook.sheets; list = []; for i in worksheet: sheet_name = i.name; print (i.name); list .append(sheet_name); print ( list ); workbook.close(); app.quit(); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #打开有密码的EXCEL文件 涂聚文 Geovin Du # Anaconda 5.2.0 # from win32com.client import Dispatch,DispatchEx,constants; # import win32com.client; #(pip install pypiwin32) dupath = Path( 'C:\\Users\\geovindu\\Documents\\Visual Studio 2017\\Projects\\PythonTickt\\PythonTickt\\excel\\20198HBDAY.xlsx' ); xlApp = win32com.client.Dispatch( "Excel.Application" ); xlApp.Visible = False #文档打开,不显示打开 xlApp.DisplayAlerts = True xlwb = xlApp.Workbooks. Open (dupath, False , True , None , password) print ( "Success! Password is: " + password) dusheet = xlwb.sheets; dulist = []; for i in dusheet: duname = i.name; print (i.name); dulist.append(duname); print (dulist); xlwb.Close( False ); #涂聚文 Geovin Du 关闭 xlApp.Quit(); #退出 |
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
2015-12-07 sql server: sql script