Microsoft Office Tutorials and References
In Depth Information
Excel Services and ECMAScript
You can use JSOM to retrieve data from sheets, tables, PivotTables, chart, and cells or a range of cells. You can subscribe
to many events in order to handle various user actions, such as active selection changed or cell value editing.
JSOM is very simple to use. All you need is to write some JavaScript and add it to the page either directly or by
using the Content Editor Web Part. The JSOM classes and members are available in the EwaMoss.js file located in the
%ProgramFiles%\Common Files\Microsoft Shared\Web server extensions\15\template\layouts directory.
reference to ewaMoss.js, by default, is available in the default master page. You need to refer to the file when
custom master pages are designed.
Note
Let’s now see how to use JSOM to retrieve data from an Excel workbook that is published to SharePoint 2013.
prOBLeM CaSe
retrieve a selected range of cell values, and display them on the page using the JavaScript Object Model. Use the
excel workbook you created using SSaS data earlier in this chapter.
Solution
You’ve already performed a similar kind of exercise earlier in Chapter 2 to retrieve the data. We will follow the
same methodology to retrieve data from the excel workbook in this case. the major steps involved in this exercise
are as follows:
1.
First, add the page-load event handler:
window.attachEvent("onload", Page_Load);
2.
On page load, create a delegate method for “applicationready” event. as soon as the excel
Services JavaScript Object Model is ready, this delegate method will be called:
Ewa.EwaControl.add_applicationReady(GetEwaWebpart);
3.
When the delegate method is called, get the instance of the excel Web part on the page. in
the code, index 0 is used with the expectation that only one instance of the eWa Web part
is available:
ewaWebPart = Ewa.EwaControl.getInstances().getItem(0);
4.
verify whether the instance of eWa is available, and add the ActiveSelectionChanged event
handler to the excel Web access Web part instance:
ewaWebPart.add_activeSelectionChanged(activeSelectionChangedHandler);
 
 
Search JabSto ::




Custom Search