Excel Services REST APIs – the basics
Last week I posted a number of pieces about the various ways the new Excel Services REST APIs allows developers to leverage data and elements from within workbooks by giving direct URLs to them. This post contains details about the available capabilities of the REST APIs – essentially a list of all the entities that are available for deep-linking.
All the relative URLs presented are based off the base REST URL which I explained in the very first post – the base URL essentially follows the following template:
https://[server]/_vti_bin/ExcelRest.aspx/[DocLib]/[File.Xlsx]
The following table shows all the accessible resources off this base URL:
Resource | Format | Example | Notes |
/Model | atom (default) | This returns an ATOM feed with the resources supported by the workbook (Ranges, Charts, PivotTables and Tables). | |
/Model | workbook | /Model?$format=workbook | The binary workbook (the xlsx/xlsb/xlsm) itself. |
/Model/Ranges | atom (default) | /Model/Ranges/Model/Ranges?$format=atom | An ATOM feed listing all the named ranges in the workbook. |
/Model/Ranges('[Name]') | html (default) | /Model/Ranges('MyRange')/Model/RangeS('MyRange')?$format=html | An HTML fragment for the requested range. |
/Model/Ranges('[Name]') | atom | /Model/Ranges('MyRange')?$format=atom | An ATOM entry containing an XML representation of the data within the range. |
/Model/Charts | atom (default) | /Model/Charts/Model/Charts?$format=atom | An ATOM feed listing all the charts in the workbook. |
/Model/Charts('[Name]') | image (default) | /Model/Charts('MyChart')/Model/Charts('MyChart')?$format=image | An image (PNG form) of the chart. |
/Model/Tables | atom (default) | /Model/Tables/Model/Tables?$format=atom | An ATOM feed listing all the available tables in the workbook. |
/Model/Tables('[Name]') | html (default) | /Model/Tables('MyTable')/Model/Tables('MyTable')?$format=html | An HTML fragment for the requested table. |
/Model/Tables('[Name]') | atom | /Model/Tables('MyTable')?$format=atom | An ATOM entry containing an XML representation of the data within the table. |
/Model/PivotTables | atom (default) | /Model/PivotTables/Model/PivotTables?$format=atom | An ATOM feed listing all the available PivotTables in the workbook. |
/Model/PivotTables('[Name]') | html (default) | /Model/PivotTables('MyPT')/Model/PivotTables('MyPT)?$format=html | An HTML fragment for the requested PivotTable. |
/Model/PivotTables('[Name]') | atom | /Model/PivotTables('MyPT')?$format=atom | An ATOM entry containing an XML representation of the data within the PivotTables |
As you can see, there are a number of elements inside workbooks that are addressable via a URL. For example, the table I pasted in here actually resides within Excel Services. This means that it is addressable via the /Model/Tables(‘[Name]’) rows. The following example shows this very same table accessed in IE by a direct link:
The name of the table is “Table1” – because the HTML format is the default one when accessing tables, that means that one does not need to specify it to get HTML back.
That’s it for now. The next post will show you a solution written using REST which will allow end users to put refreshable data from Excel Services on their desktop via a relatively simple Windows 7 Gadget.
Comments
- Anonymous
May 08, 2012
is there a way to determine the range on a worksheet that isnt defined? I saw from your other post that you can put in a range using "|", but if your target workbook has variable sized ranges and no range names, how would you get the exact range of data?