業界トップクラスの求人数を誇る転職エージェントPR

リクルートグループのコネクションを活かした非公開求人も充実、他にはない好条件の求人と出会える

4
4

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.

DataNitro、シートからデータを読み込む関数の実装

Last updated at Posted at 2014-06-22

privateで少し勉強した位でしばらく放置していたけど、DataNitroをインストールしたので、久しぶりにpythonをいじってみている。
DataNitroなので、(excel)シートからデータを読み込む関数を実装。

def get_sheet_data(shtnam, toprow, keyclm, lftclm, rgtclm):
    row = toprow
    while Cell(shtnam, row, keyclm).value != None:
        row += 1
    if row > toprow:
        return CellRange(shtnam, (toprow, lftclm), (row - 1, rgtclm))
    else:
        return []

キー項目になるカラムのセルが空になるまでチェックするところは、vbaだと、

    Range(sheets(shtnam).Cells(toprow, keyclm), _
            sheets(shtnam).Cells(toprow, keyclm)).Select
    Selection.End(xlDown).Select

として、Selection.rowを参照する実装で調べることができるけど、DataNitroだと
セルを1つ1つ見ていくやり方しかなさそう。
あと、シート上のボタンとかのコントールにアクセスする方法もなさそう。

pythonはあまり使ったことがないけど、クラスとか調べてややこしいなーと、感じてしまった。
この辺は別の記事で書こうかと。

4
4
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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?