Excel Services REST API の検出

最終更新日: 2010年4月14日

適用対象: SharePoint Server 2010

このトピックでは、Excel Services REST API に組み込まれた検出メカニズムについて説明します。

検出ベース URL と検出の例

検出では、開発者とユーザーが手動あるいはプログラミングにより、ブックについての情報とブックの内容を検出できるようにします。検出メカニズムは、ブック内のリソースについての情報を含む Atom (英語) フィードを提供します。検出を使用することにより、ブック内のリソースを確認して、表示することができます。確認してアクセスすることができるリソースは、範囲、グラフ、表、およびピボットテーブルです。

以下は、ブック内の特定の要素に対する、REST URL のコンストラクターです。

http://<ServerName>/_vti_bin/ExcelRest.aspx/<DocumentLibrary>/<FileName>/<ResourceLocation>

基本的な URI 構造およびパス」トピックで説明されているように、以下は、sampleWorkbook.xlsx という名前のブックにアクセスし、さらに SampleChart という名前のグラフを表示するための REST URL です。

http://<ServerName>/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('SampleChart')

検出によって、ブックを開き、ブック内のリソースを確認および表示するには、この例の後の URI を使用してモデル ページを参照してください。

http://<ServerName>/_vti_bin/ExcelRest.aspx/<DocumentLibrary>/<FileName>/model

sampleWorkbook.xlsx の例を使用する場合、以下が URI です。

http://<ServerName>/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model

以下は、モデル ページのスクリーン ショットです。

Excel Services REST モデル URL

Excel Services REST モデル URL

モデル ページの URL が、検出を始める場所です。モデル ページは、Excel Services REST API が現在サポートする 4 つのリソース コレクションを表示します。リソース コレクションは、範囲、グラフ、テーブル、あるいはピボットテーブルです。モデル ページで、[Ranges]、[Charts]、[Tables]、あるいは [PivotTables] をクリックすることによって、特定のブック内のそれらのリソースを確認することができます。

たとえば、検出を使用してブック内のグラフにアクセスするには、以下の操作を実行します。

  1. モデル ページで、[Charts] をクリックします。[Charts] リンクをクリックすると別の Atom フィードが表示されます。この結果のフィードは、sampleWorkbook.xlsx ブックで使用可能なすべてのグラフを列挙します。sampleWorkbook.xlsx ブックには、Chart 1Chart 3、および SampleChart という名前の 3 つのグラフが含まれます。このため、以下のスクリーン ショットのように、3 つのグラフ名が示されています。

    Excel Services REST 検出チャート リスト

  2. モデル ページで、[SampleChart] をクリックします。これにより、以下のスクリーン ショットで示されるように、sampleWorkbook.xlsx 内の SampleChart という名前のグラフが表示されます。

    REST を使用したグラフの表示

    REST を使用したチャートの表示

  3. 同様に、[Chart 1] あるいは [Chart 3] をクリックすると、対応する名前のグラフが表示されます。[SampleChart] をクリックすると、実際のグラフ URL に移動します。以下が、SampleChart の画像の (スクリーン ショットを参照) URL です。

    http://<ServerName>/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('SampleChart%20')?$format=image
    

Atom フィード

REST API が提供する Atom (英語) フィードを使用すると、興味のあるデータを簡単に入手できます。Web ページのソースを表示すると、XML を取得できます。sampleWorkbook.xlsx のグラフの例を、以下に示します。

XML に示されているように、フィードには、ブック内にどんな要素が存在するかコードが検出できるようにする、トラバース可能な要素が含まれます。それぞれの Atom エントリが、アクセスできるグラフに対応します。この同じメカニズムは、範囲、表、およびピボットテーブルの検出にも当てはまります。

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:x="https://schemas.microsoft.com/office/2008/07/excelservices/rest" xmlns:d="https://schemas.microsoft.com/ado/2007/08/dataservice" xmlns:m="https://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <title type="text">Charts</title>
  <id>https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts</id>
  <updated>2010-01-19T19:32:53Z</updated>
  <author>
    <name />
  </author>
  <link rel="self" href="https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts?$format=atom" title="Charts" />
  <entry>
    <category term="ExcelServices.Chart" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <title>Chart 1</title>
    <id>https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('Chart%201')</id>
    <updated>2010-01-19T19:32:53Z</updated>
    <author>
      <name />
    </author>
    <link rel="alternate" title="Chart 1" href="https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('Chart%201')?$format=image" />
    <content type="image/png" src="https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('Chart%201')?$format=image" />
  </entry>
  <entry>
    <category term="ExcelServices.Chart" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <title>Chart 3</title>
    <id>https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('Chart%203')</id>
    <updated>2010-01-19T19:32:53Z</updated>
    <author>
      <name />
    </author>
    <link rel="alternate" title="Chart 3" href="https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('Chart%203')?$format=image" />
    <content type="image/png" src="https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('Chart%203')?$format=image" />
  </entry>
  <entry>
    <category term="ExcelServices.Chart" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <title>SampleChart </title>
    <id>https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('SampleChart%20')</id>
    <updated>2010-01-19T19:32:53Z</updated>
    <author>
      <name />
    </author>
    <link rel="alternate" title="SampleChart" href="https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('SampleChart%20')?$format=image" />
    <content type="image/png" src="https://ServerName/_vti_bin/ExcelRest.aspx/Docs/Documents/sampleWorkbook.xlsx/model/Charts('SampleChart%20')?$format=image" />
  </entry>
</feed>

関連項目

概念

Excel Services REST API のためのリソース URI