0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

openpyxl keyerror 31

Last updated at Posted at 2019-10-02

ライブラリopenpyxlでエクセルファイルを読み込む時、エラーが発生しました。

book = load_workbook("db.xlsx")```

以下のエラーが発生しました。
  ```File "C:\Users\en_pm\PycharmProjects\cunit_tool\venv\lib\site-packages\openpyxl\styles\stylesheet.py", line 166, in _normalise_numbers
    fmt = BUILTIN_FORMATS[style.numFmtId]
KeyError: 31```

ネットで調べますと、セルの日付のフォーマットの原因です。
ユーザー定義のフォーマットがOpenpyxlで解析できないため。
![キャプチャ.PNG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/197197/b9206680-14b5-cbf9-6154-9f94978a0934.png)

セルの表示形式に’日付’を設定すると、うまく解決しました。


0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?