V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
leisurelylicht
V2EX  ›  Python

关于 openpyxl 的使用方法

  •  
  •   leisurelylicht · May 17, 2017 · 2458 views
    This topic created in 3266 days ago, the information mentioned may be changed or developed.

    请问在 openpyxl 中如何判断一个单元格的类型?

    类似于 xlrd 中的

    sheet.cell_type(row, 8) == xlrd.XL_CELL_DATE

    openpyxl 中关于数据格式的定义如 xlrd.XL_CELL_DATE,xlrd.XL_CELL_NUMBER 之类的是在哪定义的?

    3 replies    2017-05-17 16:19:45 +08:00
    weyou
        1
    weyou  
       May 17, 2017
    type(ws.cell(row=1, column=1).value)
    leisurelylicht
        2
    leisurelylicht  
    OP
       May 17, 2017
    @weyou openpyxl 直接使用了 python 的内置类型吗?
    weyou
        3
    weyou  
       May 17, 2017
    @leisurelylicht cell 的值在读取 /写入的时候 openpyxl 会负责映射 Excel 数据类型 to/from 相应的 Python 类型
    你也可以用 ws.cell(row=1, column=1).data_type 查看数据类型。不过一般 data_type 很少用到,直接查看 value 的类型就好了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4366 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 05:31 · PVG 13:31 · LAX 22:31 · JFK 01:31
    ♥ Do have faith in what you're doing.