Skip to Content
エクセルのためのPython (Japanese Edition), 2nd Edition
book

エクセルのためのPython (Japanese Edition), 2nd Edition

by Felix Zumstein
May 2026
Intermediate
418 pages
6h 42m
Japanese
O'Reilly Media, Inc.
Content preview from エクセルのためのPython (Japanese Edition), 2nd Edition

第10章 Pythonパッケージトラッカー

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

この章では、インターネットからデータをダウンロードし、データベースに保存してからExcelで可視化する、典型的なビジネスアプリケーションを作成する。これにより、このようなアプリケーションにおいてxlwingsがどのような役割を果たすかを理解でき、Pythonを使って外部システムに接続することがいかに簡単であるかを確認できる。 実世界のアプリケーションに近いながらも、比較的理解しやすいプロジェクトを構築しようと試みた結果、特定のPythonパッケージの年間リリース数を表示するExcelツール「Pythonパッケージトラッカー」を考案した。これはケーススタディではあるが、特定のPythonパッケージが活発に開発されているかどうかを判断する上で、実際に役立つツールとなるかもしれない。

アプリケーションに慣れた後、そのコードを理解するために必要ないくつかのトピックを見ていく。アプリケーション開発において重要な概念であるPythonの例外処理について学ぶ前に、インターネットからデータをダウンロードする方法や、データベースとやり取りする方法を確認する。 これらの準備が整ったら、Python Package Trackerの構成要素を順を追って確認し、全体がどのように連携しているかを理解する。この章の締めくくりとして、xlwingsコードのデバッグ方法についても見ていく。前の2章と同様、この章を進めるには、WindowsまたはmacOSにMicrosoft Excelがインストールされている必要がある。それでは、Python Package Trackerを試用してみよう!

実際に試してみる

ユーザ視点でPackage Trackerの仕組みを理解するには、実際に試してみるのが一番だ。付属のリポジトリに移動し、packagetrackerフォルダを探そう。そのフォルダにはいくつかのファイルがあるが、まずはExcelファイルpackagetracker.xlsmを開いてみよう。

マクロを有効にする

packagetracker.xlsmのようなマクロ有効ワークブック(拡張子xlsm)を開く際は、でマクロを適切に有効にするように注意する。

  • 「コンテンツを有効にする」をクリックする。

  • インターネット上のxlsmファイルを扱う場合は、さらに「編集を有効にする」をクリックする必要がある。

  • ただし、ワークブックを開く前に、Windowsのファイルエクスプローラーでファイルを右クリックし、「プロパティ」を選択して、ファイルのブロックを解除する必要があるかもしれない。「全般」タブで「ブロックを解除」のチェックボックスをオンにし、「OK」をクリックしてプロパティウィンドウを閉じる(macOSではファイルのブロック解除は不要だ)。

次に、「Database」シートを開こう。作業の材料とするため、まずデータベースにデータを登録する必要がある。図10-1に示すように、パッケージ名を入力する。例えば xlwingsと入力し、「Add Package」をクリックする。Python Package Index(PyPI) に存在する任意のパッケージ名を選択できる。

macOS:フォルダへのアクセスを確認

macOSで最初のパッケージを追加する際、アプリケーションがpackagetrackerフォルダにアクセスできるよう、ポップアップ(「Microsoft ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

大規模言語モデル:難しい部分 (Japanese Edition)

大規模言語モデル:難しい部分 (Japanese Edition)

Thársis T. P. Souza, Jonathan K. Regenstein

Publisher Resources

ISBN: 0642572395971