REST API in SharePoint 2010 for Excel Services: Part 3


In this article we will be seeing how to access the Tables and REST API Return Formats. Here is Part 2

Table:

RAPIShare1.gif

URL Structure:

We can access resources like charts, PivotTables, tables, and named ranges in a workbook directly through a URL using REST API. Each REST URL in Excel Services is built of three parts.

  1. REST aspx Page URI The entry point to an .aspx page
  2. Workbook Location The path to the workbook
  3. Resource Location The path to the requested resource inside the workbook

Example:

http://servername:1111/sites/VJTesting/_vti_bin/excelrest.aspx/Shared%20Documents/ExcelChart.xlsx/model
REST aspx Page URI - http://servername:1111/sites/VJTesting/_vti_bin/excelrest.aspx

Workbook Location - /Shared%20Documents/ExcelChart.xlsx

Resource Location- /model

We can use the resource location to get the particular element from the excel workbook.

RAPIShare2.gif

Tables:

In this section we will be seeing how to access the tables using the REST URL.

REST URL:

http://serverName:1111/sites/VJTesting/_vti_bin/excelrest.aspx/Shared%20Documents/ExcelChart.xlsx/model/Tables('EmpDetails')

REST aspx Page URI - http://servername:1111/sites/VJTesting/_vti_bin/excelrest.aspx

Workbook Location - /Shared%20Documents/ExcelChart.xlsx

Resource Location- /model/Tables('EmpDetails')

The output will be as shown in the following

RAPIShare3.gif

REST API Return Formats:

REST API supports the following return formats

  • html
  • atom
  • image
  • workbook

?$format=html - REST API returns an HTML representation of the item that can be displayed by the web browser.
?$format=atom - REST API returns an ATOM feed representation of the item.
?$format=image - REST API returns an image file (format is always PNG).
?$format=workbook - REST API returns the workbook which can then be opened in Excel or saved.

Item

Format

Top of Form

/ModelBottom of Form

?atom, ?workbook

/Model/Ranges

?atom

/Model/Ranges('RangeName')

?atom, ?html

/Model/Charts

?atom

/Model/Charts('ChartName')

?atom, ?image

/Model/Tables

?atom

/Model/Tables('TableName')

?atom, ?html

/Model/PivotTables

?atom

/Model/PivotTables('PivotTableName')

?atom, ?html Bottom of Form