製品をチェック

無償トライアル:

無償トライアルへ

製品の情報と無償トライアルへ:

SharePoint Excel Services Python Connector

SharePoint Excel Services データ連携用のPython Connector ライブラリ。pandas、SQLAlchemy、Dash、petl などの主要なPython ツールにSharePoint Excel Services をシームレスに統合。

Python pandas を使ってSharePoint Excel Services データをビジュアライズ


CData Python Connector for ExcelServices を使えば、Python でSharePoint Excel Services をpandas などのライブラリで呼び出し、データ分析やビジュアライズが可能になります。


古川えりか
コンテンツスペシャリスト

excelservices ロゴ画像

Python

python ロゴ画像
pandas ロゴ画像

こんにちは!コンテンツスペシャリストの古川です。Python エコシステムには多くのライブラリがあり、開発やデータ分析を行う際には必須と言っていいライブラリも多く存在します。CData Python Connector for ExcelServices は、pandas、Matplotlib、SQLAlchemy から使用することで SharePoint Excel Services にデータ連携するPython アプリケーションを構築したり、SharePoint Excel Services データの可視化を実現します。本記事では、pandas、SQLAlchemy、およびMatplotlib のビルトイン機能でSharePoint Excel Services にリアルタイムアクセスし、クエリを実行して結果をビジュアライズする方法を説明します。

CData Python Connector は、ビルトインされた効率的なデータプロセスにより、リアルタイムSharePoint Excel Services データにPython からアクセスし、高いパフォーマンスと接続性を発揮します。SharePoint Excel Services に複雑なクエリを投げる際に、ドライバーはフィルタリング、集計などがサポートされている場合、SQL 処理を直接SharePoint Excel Services 側に行わせ、サポートされていないSQL 処理については、組み込まれたSQL エンジンによりクライアント側で処理を行います(特にJOIN やSQL 関数など)。

SharePoint Excel Services データへの接続

まずは、右側のサイドバーからCData Pytthon Connector の無償トライアルをダウンロード・インストールしてください。必要な接続プロパティを使って接続文字列を作成します。本記事では、接続文字列をcreate_engine 関数のパラメータとして送ります。

Authentication セクションのURL、User、およびPassword プロパティを、SharePoint Online、SharePoint 2010、SharePoint 2013 の有効なクレデンシャルに設定します。さらに、Library プロパティを有効なSharePoint Document ライブラリに設定し、File プロパティを指示されたライブラリの有効な.xlsx ファイルに設定する必要があります。

以下の手順に従い、必要なライブラリをインストールし、Python オブジェクト経由でSharePoint Excel Services にアクセスします。

必要なライブラリのインストール

pip で、pandas & Matplotlib ライブラリおよび、SQLAlchemy をインストールします。

pip install pandas
pip install matplotlib
pip install sqlalchemy

次にライブラリをインポートします。

import pandas
import matplotlib.pyplot as plt
from sqlalchemy import create_engine

Python でSharePoint Excel Services データをビジュアライズ

次は接続文字列を作成してSharePoint Excel Services に接続します。create_engine 関数を使って、SharePoint Excel Services に連携するEngne を作成します。以下はサンプルの接続文字列になりますので、環境に応じてクレデンシャル部分を変更してください。

engine = create_engine("excelservices:///?URL=https://myorg.sharepoint.com&User=admin@myorg.onmicrosoft.com&Password=password&File=Book1.xlsx")

SharePoint Excel Services にアクセスするSQL を実行

pandas のread_sql 関数を使って好きなSQL を発行して、DataFrame にデータを格納します。

df = pandas.read_sql("""SELECT Name, AnnualRevenue FROM Account WHERE Industry = 'Floppy Disks'""", engine)

SharePoint Excel Services データをビジュアライズ

DataFrame に格納されたクエリ結果に対して、plot 関数をつかって、SharePoint Excel Services データをグラフ化してみます。

df.plot(kind="bar", x="Name", y="AnnualRevenue")
plt.show()
SharePoint Excel Services data in a Python plot (Salesforce is shown).

製品の無償トライアル情報

SharePoint Excel Services Python Connector の30日の無償トライアル をぜひダウンロードして、SharePoint Excel Services への接続をPython アプリやスクリプトから簡単に作成しましょう。



ソースコード

import pandas
import matplotlib.pyplot as plt
from sqlalchemy import create_engin

engine = create_engine("excelservices:///?URL=https://myorg.sharepoint.com&User=admin@myorg.onmicrosoft.com&Password=password&File=Book1.xlsx")
df = pandas.read_sql("""SELECT Name, AnnualRevenue FROM Account WHERE Industry = 'Floppy Disks'""", engine)

df.plot(kind="bar", x="Name", y="AnnualRevenue")
plt.show()