Help us understand the problem. What is going on with this article?

openpyxl と xlwings の名前付き範囲

More than 1 year has passed since last update.

よく使う API の比較

openpyxl xlwings 内容
px.workbook.defined_name.DefinedNameList xw.main.Names Names 型相当
px.workbook.defined_name.DefinedName xw.main.Name Name 型相当
names = wb.defined_names names = wb.names Workbook.Names 相当
name = names['ブック単位範囲名'] name = names['ブックorシート単位範囲名'] ネーム情報
name = names.get('ブック単位範囲名')
name = names.get('シート単位範囲名', False)
name.attr_text name.refers_to[1:] アドレスを得る
[wb[s][r] for s, r in name.destinations] name.refers_to_range セルor範囲を得る

サンプル

openpyxlサンプル

本家説明 がざっくり過げててアレ。

names = wb.defined_names
name = names['ブック単位範囲名']
name = names.get('ブック単位範囲名')
name = names.get('シート単位範囲名', False)
cells = [wb[s][r] for s, r in name.destinations]

# シートインスタンスからも手繰れるが deprecated 扱いになっている
cells = wb['シート名'].get_named_range('ブック単位範囲名')

xlwingsサンプル

rng = wb.sheets['シート名']['範囲名']
m5knt
C++,C#,Python あたりを使っていたおじさんにゃーん にゃーんとか言っちゃうキモイおっさんにゃーん #付きタイトルを記事の根元にしていますにゃーん
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした