首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Python读取excel表格(xlsx)中带有某种背景颜色的单元格

Python读取excel表格(xlsx)中带有某种背景颜色的单元格
EN

Stack Overflow用户
提问于 2018-09-06 02:46:13
回答 1查看 1.5K关注 0票数 1

我正在尝试读取excel sheet(xlsx),它使用背景颜色来区分值。

我尝试了下面的库:

  1. pandas找不到任何选项来读取基于背景色的单元格。
  2. xlrd。

导入formatting_info=True) xlrd.open_workbook("filename.xlsx",xlrd

它给出的错误是: NotImplementedError: formatting_info=True尚未实现。

  1. StyleFrame (如DeepSpace在:根据excel表格中的单元格颜色和文本颜色设置数据框子集)

从StyleFrame导入StyleFrame中,utils sf = StyleFrame.read_excel('filename.xlsx',read_style=True,from

它给出的错误如下:

代码语言:javascript
复制
Traceback (most recent call last):
File "proj_path/read_excel.py", line 22, in <module>
sf = StyleFrame.read_excel('filename.xlsx', read_style=True, use_openpyxl_styles=False)
File "C:\Anaconda\lib\site-packages\StyleFrame\deprecations.py", line 22, in inner
return func(*args, **kwargs)
File "C:\Anaconda\lib\site-packages\StyleFrame\style_frame.py", line 220, in read_excel
_read_style()
File "C:\Anaconda\lib\site-packages\StyleFrame\style_frame.py", line 209, in _read_style
read_comments and current_cell.comment)
File "C:\Anaconda\lib\site-packages\StyleFrame\styler.py", line 127, in from_openpyxl_style
font_color = theme_colors[openpyxl_style.font.color.theme]
TypeError: list indices must be integers or slices, not Integer

任何帮助我朝着正确方向前进的建议都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2018-09-06 02:52:55

即使可以通过Python,最简单的方法应该是在Excel中按颜色过滤,复制该表并将其粘贴到其他地方,然后导入它,就像使用Pandas导入任何Excel文件一样。

正如DeepSpace评论的那样,它以前也是通过Python完成的,但它相当麻烦

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52191644

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档