0221 解决万得导出数据excel无法python读入的问题

报错如下: TypeError: <class 'openpyxl.styles.named_styles._NamedCellStyle'>.name should be <class 'str'> but value is <class 'NoneType'>

原因分析:

万得导出的xlsx带有某些格式,比如首行加粗,excel桌面端工具能打开,但openpyxl报错,导致无法批量处理 ,

修改方法:

使用python3.8 安装旧版pandas和xlrd,并在pandas代码中指定引擎使用xlrd

\Python38\Scripts\pip.exe install pandas==1.3.5 -i https://pypi.tuna.tsinghua.edu.cn/simple

\Python38\Scripts\pip.exe install xlrd=1.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

pd .read_excel (pdf_path, usecols=None, engine='xlrd')

提供解决思路的原文地址:

agileminorcommented on Apr 29, 2022

I found a different work around - in pandas 1.3.5 (or earlier) and xlrd version < 2.0, use engine='xlrd' and the ViCell file can be opened successfully.

来自 <BUG: pandas cannot open xlsx with openpyxl engine · Issue #40499 · pandas-dev/pandas · GitHub>

最后使用python38就可以使用了。

C:\Users\charlie\AppData\Local\Programs\Python\Python38\python.exe mergeTables.py

相关推荐
低维歌者15 分钟前
python训练营day27
java·开发语言·python
微刻时光23 分钟前
影刀处理 Excel:智能工具带来的高效变革
人工智能·python·低代码·自动化·excel·rpa·影刀rpa
大帅不是我24 分钟前
Python多进程编程执行任务
java·前端·python
Fu_lucas28 分钟前
Python Logging 模块完全指南
开发语言·python
Ciito29 分钟前
将 Element UI 表格元素导出为 Excel 文件(处理了多级表头和固定列导出的问题)
前端·vue.js·elementui·excel
Eiceblue30 分钟前
Python 在Excel单元格中应用多种字体样式
开发语言·vscode·python·pycharm·excel
Superstarimage2 小时前
使用conda创建python虚拟环境,并自定义路径
windows·python·conda
菜鸡码农,喵。2 小时前
已经装了pygame但pycharm显示没有该模块/软件包无法加载出来下载pygame
python·pycharm·pygame
小羊Linux客栈2 小时前
自动化:批量文件重命名
运维·人工智能·python·自动化·游戏程序
shykevin5 小时前
python开发Streamable HTTP MCP应用
开发语言·网络·python·网络协议·http