Skip to main content

Excel Services in SharePoint 2010


Excel services is yet another important pillar in Microsoft’s business intelligence offering. Business users really like Excel because it is easy to use and they can add complex formulas to Excel to express their logic. They can do so without involving the IT guy. The problem with this scenario, however, is that it becomes very difficult to share some Excel sheets with their coworkers. Usually users prefer to send workbooks via email, but sometimes the workbooks are too large for email, sometimes they have backend data connections, and sometimes workbooks send via email cause version confusion hell.

Excel Services solves all of these problems. In short, Excel Services allow you to publish an Excel workbook in a document library. The Excel workbook is then calculated on the server, and is then presented to one or more clients. In the calculation, Excel workbooks can involve external data sources or even custom UDFs (user defined functions) written in .NET. Once you publish the Excel workbook (though you could publish just a worksheet or even just an object like a chart), other persons, applications or services with access to the server can consume it directly through the browser by using the Excel WebApplication component, Excel Web Access Web Part, or ExcelService.asmx Web service. The Excel workbook functionality is also available over REST-based APIs and thus can be exposed as Atom feeds or JSON.
Let’s look at a practical example. Start by setting up the Northwind Traders database in a SQL server. You will find the script to set up the Northwind database in the associated code download of this article. Next I’ll craft an Excel workbook that displays orders information from this database as a pivot table and pivot chart.
Start Excel 2010 and click the Data tab in the ribbon, choose "From other sources" and choose to import data from SQL server. You have the ability to import data from various other sources as well. When prompted to import data from SQL server, choose to import the data from the orders table in the Northwind database using Windows authentication. You could have also chosen to use SQL Server authentication or to provide a secure store service ID and get credentials at runtime. Once you have finished importing the data from SQL Server, choose to save the .odc file in a SharePoint "Data Connections Library" that you will need to create beforehand.
At this point, Excel will prompt you to import the data as either a table, a pivot table, or a pivot table and pivot chart. Choose to import the data as a pivot table and pivot chart.
Now in the pivot table, make the following changes:
  1. Make ShipCountry the Report Filter.
  2. Make ShipCity and ShippedDate Row Labels.
  3. Show Sum of Values using the Freight column.
Choose to make USA as the filtered selected country. Your pivot table should look like Figure 1.
Click for a larger version of this image.

Figure 1: My PivotTable.


Note that the pivot chart has been updating itself and is showing you a graphical view of the data you see in the pivot table. Thus the pivot chart and pivot table are connected with each other. I’ll format the chart a bit and will choose to show a line graph instead of a bar chart (Figure 2).
Click for a larger version of this image.

Figure 2: The PivotTable.


Next add a column next to the pivot table and give it a heading of "Difference from Avg.". Give it a formula of "=B4-AVERAGE(B4:B15)" and choose to repeat this formula on all available cells. Also, apply conditional formatting to this cell so it graphically shows you all cities that have freight less than or greater than average. My pivot table now looks like Figure 3.
Click for a larger version of this image.

Figure 3: Databars added within each cell in my pivot table.


Finally, select that A1 cell in the pivot table to make the Options tab in the Ribbon visible. With the Options visible, click on Insert Slicer, and choose to make ShipRegion available in the slicer. This will allow you to slice the data at runtime and subsequently affect the pivot table and pivot chart.
You can see my final Excel sheet in Figure 4.
Click for a larger version of this image.

Figure 4: The final Excel sheet.


Now from the Backstage view of Excel 2010, click Share, and choose to publish this workbook to Excel Services. For now, publish this workbook to a document library called Sheets. You will have to pre-create this document library in your site collection. Also, you will need to pre-activate the enterprise features in your site collection. And if you have used Excel Services with SharePoint 2007, you would remember that at this point you would also have to go into Central Administration and add a trusted file location. In SharePoint 2010 this isn’t necessary because by default, all SharePoint sites are available as trusted file locations. You can verify this by going to the Central Administration | Application Management section, click Manage service applications, and choose to manage the Excel Services service. Click on Trusted file locations, and you should see an entry as shown in Figure 5.
Click for a larger version of this image.

Figure 5: Trusted file locations within SharePoint for Excel Services.


As you can guess, this entry makes the entire SharePoint farm available as a trusted file location.
With the Excel workbook published, drop the Excel Web Access Web Part on the homepage of your SharePoint site collection and configure it to show your newly published Excel workbook. You should see your Excel workbook running with full interactivity in the pivot table, pivot chart, the slicer, and showing live data from the Northwind database. You can see this in Figure 6.

Click for a larger version of this image.

Figure 6: The Excel workbook running in Excel Services 2010.

Now this is a very compelling example. The end business user can craft up such workbooks talking to real data and publish them for the world to see. It gets more interesting than this. For the current web session, these workbooks can be edited in the browser and can recalculate themselves and present new data. Excel Services also have the ability to parameterize certain sheets. Also, the logic of the workbooks is exposed over a Web service and REST API. Let’s look at that next.

Accessing Excel Services Over REST

Here is the best news. The Excel workbook that you have so far been working with is already being exposed over the REST-based API. Don’t believe me? Assuming that your Excel workbook is called Northwind Orders.xlsx, visit the following URL:
http://sp2010/_vti_bin/ExcelRest.aspx/Sheets/Northwind%20Orders.xlsx/model
As you will note, the above URL provides you with all the details embedded in your Excel workbook over an Atom feed. Now visit the following URL:
http://sp2010/_vti_bin/ExcelRest.aspx/Sheets/Northwind%20Orders.xlsx/model/Charts('Chart%201')?$format=image
You would note that your Excel workbook chart is being exposed as a simple image. This is really useful. I’m going to show a practical demonstration of this. Imagine that your task is to craft up a document that shows the graph of the freight cost for USA. Usually what you would do is copy and paste such a chart from an existing resource and embed it in the document. That is not a perfect approach because sooner or later the chart will become out of date. You can, however, use Excel Services to create a chart that updates with live data every time the document is opened. To do so, start Word 2010, and under the Insert tab click on Quick Parts. Choose to include a new field and in the ensuing dialog box choose to "IncludePicture" and provide the appropriate URL as shown in Figure 7.
Click for a larger version of this image.

Figure 7: Customizing the QuickPart in Word.


Doing so will immediately insert a chart from the Web-based URL, and every time the Word document is opened this chart will automatically be refreshed. You can see this in Figure 8.
Click for a larger version of this image.

Figure 8: Data coming from Excel Services, embedded in Word.


It goes without saying that you can embed this chart in any Web-based content such as a content editor Web Part, a blog post, or even a non-SharePoint application. What is really compelling is that this functionality of Excel Services as an Atom-based feed is available on SkyDrive in the cloud as well. So you can technically host Excel workbooks in your SkyDrive and have those generate graphs that can be embedded in your blog posts.
Not only can you embed charts, you can embed any content being exposed by an Excel workbook into any other consumer. For instance, now try visiting the URL shown below:
http://sp2010/_vti_bin/ExcelRest.aspx/Sheets/Northwind%20Orders.xlsx/model/PivotTables('PivotTable1')?$format=html
Note the end of the query string parameter in the above URL. By default, the content is exposed as Atom feeds, but you can choose to request JSON or even HTML.
The above URLs render an HTML table as shown in Figure 9.
Click for a larger version of this image.

Figure 9: Data coming from Excel Services, available as an HTML table.


You can embed this HTML table into any container that can render HTML. This can be your browser, Word or Excel, or something else. For instance, to insert this content into Word again, choose to insert a Quick Part but this time, choose to insert using “IncludeText.”
Accessing Excel Services over SOAP

Just as you’re able to access Excel workbooks over REST-based APIs, they are also exposed over SOAP-based APIs. This is not very different from what was available in SharePoint 2007 as the ExcelService.asmx. The following article describes the process of using a WCF client to talk to ExcelService.asmx in SharePoint 2007, and the same technique will work in SharePoint 2010 as well.
Summary

SharePoint 2007 presented the first iteration of Excel Services. Microsoft created it in response to market demand - Excel is perhaps the most commonly used database in the world. Yes, I called it a database!
Excel Services 2010 furthers this product by introducing support for newer features in Excel 2010, and the inclusion of a REST-based API to access Excel Services 2010. This truly makes the product a lot more compelling.
Happy SharePointing.

Comments

Popular posts from this blog

Sharepoint 2010 Subsites webpart

This posting was originally made by Arild Aarnes and it is in here . This is a simple webpart to show a list (with links) of subsites immediately below the current site. This webpart will work on both Sharepoint 2010 and Sharepoint Foundation. On Sharepoint 2010 you could have used the built in “Table of Contents” webpart to do similar things but this one can also display the list as a dropdown list to save space on the webpage and it can open links in a new window. All the settings can by edited in the webpart configuration panel. The settings are: Show bullet in list – this will display the small square gif in front of the site name Open link in new window – this will open the subsite in a new window Show Site Description – this will show the description you entered when you created the subsite Show icon – Shows a icon for the type of subsite, see picture. Show as dropdown list – Will display the subsites in a dropdown box to save space. The webpart can be downl

Configuring the User Profile Service in SharePoint 2010

I will share with you my step by step guide in setting up the User Profile Service application, focusing on its configuration and administration and how we can enable the creation of user profiles via an Active Directory import . SharePoint 2010 introduces the notion of “Service Applications” which build’s upon the “Shared Services Provider (SSP)” which was introduced in SharePoint 2007.  Service Applications are individual services that can be configured independently and can be shared across other sites within your farm with some service applications that can also be configured across farms. The individual service applications provided with SharePoint 2010 are listed as follows; Access Services Business Data Connectivity Document Conversion Excel Services Managed Metadata Service PerformancePoint Search Service Secure Store State Service Visio Graphics Service User Profile Service This article will build upon our initial SharePoint 2010 install utilizing the least privi

The Text Filter Web Part – Without Having To Filter Exact Text

This posting I took it from  Here   This applies to both SharePoint 2007 and 2010.  In MOSS Enterprise, and the 2010 version of Enterprise.  There is an out-of-box web part called the Text Filter Web Part .  Basically, when you put this web part on a page, and put a list or library web part on the same page, you then create a web part connection that sends the text typed in the box as a filter to one of the columns in the web part, like this: The name Molly Clark had to be typed in exactly.  So, if you typed “Molly”, this record would not come up.  People use the text filter web part when they just want to search a single column in a list or library.  Otherwise, you’d simply use the “Search” box at the top of the screen, choose “This List” or “This Site” and perform SharePoint searches that way. One more note before I get into today’s solution: If you’re making use of site columns in your lists, there’s a setting where you can specifically select which columns you do N

Telephone format for a text box on infopath form

If you want to create a Telephone format on a infopath form : 1. Add a text field to the form (Even if it is the list or a blank form) 2. Select the text box and click on Manage Rules 4. Add a rule to your textbox control with the following conditions (make sure to select "and" operator):     a. field "does not match pattern" Phone number     b. the expression: string-length(translate(., "()- ", "")) = 10     c. the expression: string-length(translate(., "()- 0123456789", "")) = 0 5. Add action to the rule:     a. Set a field's value     b. Select your textbox field     c. Insert formula for the value (click the fx button): concat("(", substring(translate(., "()- ", ""), 1, 3), ") ", substring(translate(., "()- ", ""), 4, 3), "-", substring(translate(., "()- ", ""), 7, 4)) Link for the detailed explanation :  http:

HOWTO: change the home button text on the top link bar in sharepoint 2010

Hi All, I got a requirement that the title of the site collection which shows the first button on the top link bar to be different from the title. for example: my sharepoint site title is " Srikanth SharePoint Blog" and I need to show"Home" on the top link bar. It shows Home when the publishing features are not enabled. But once the publishing features are enabled it shows the same as the title("srikanth sharepoint blog" in my case instead of "Home").In other blogs I saw the solution as "in SITE ACTIONS>SITE SETTINGS>LOOK AND FEEL> TOP LINK BAR" , but once the publishing features are enabled, you don't see the "TOP LINK BAR" under "LOOK AND FEEL"(ofcourse it is changed to "NAVIGATION" , when publishing features are enabled). In this case : 1. Hide the initial button by adding code in css.    .s4-tn li.static > a{ display: none !important; } .s4-tn li.static > ul a{ display: bloc

SharePoint Branding and Design in 2010-2

Update: Really Small SharePoint Calendar I really was not that happy with the look of the first calendar so after some modifications and a bit of CSS magic I have come up with a really good looking small calendar. At least I think so… Basically I have replaced the text of an event item with a color coded box. The benefit that you get out of this is that you don’t have to try and read the even within the small calendar but if you hover over and click on the color block you get the list Item display. Orange is for single event items (8am-10am, etc) Green is for full day events or repeat events Another nice feature to this is that I have also simplified the visual indicator when there are more then two event items in one day. Instead of seeing the arrow and text all you see is the arrow. Once you click on the arrow it will show the other blocks of events (Right image). Here is the CSS Code: Download Here Simply place a content editor web part on the same page as the calendar

SharePoint Branding and Design in 2010

Hide First Tab in SharePoint 2010 Navigation I created a blog post on this for SharePoint 2007 HERE : But SharePoint 2010 is a bit more complex. Since it uses UL’s and Li’s for it’s navigation it is a bit harder to hide just one element. You will notice that the Home tab actually is the first node and then has a child UL which represents the rest of the navigation Items. So the approach is to hide the first <li> <a> (display: none) and then simply just use (display:block ) to show the hidden <ul> <li> <a> tags. Here is the CSS you could use to hide just the first node (home) tab in a SharePoint 2010 application: .s4-tn li.static > a{ display: none !important; } .s4-tn li.static > ul a{ display: block !important; } Enjoy! Posted by Erik Swenson at 12:12 PM 2 comments Labels: Branding , CSS , SharePoint 2010 Wednesday, August 18, 2010 How To: Hide Left Side Navigation on Home Page I was recently asked: " How can I hide the sid

Data View conditional formatting using SharePoint Designer

Data View conditional formatting using SharePoint Designer This article demonstrates how to use SharePoint Designer 2010conditional formatting to format items in a SharePoint (SPS 2010) list based on item metadata. The example uses a standard SharePoint task list and formats tasks based on the due date. The end result is a list view sorted by due date with item text or background coloured to represent the number of days until the due date. The Process In this example I have started with a standard task list and have created a few sample items for testing / demonstration. From the task list, create a new view, starting from the default “Active Items” view (filtered to only display incomplete tasks). The view created in the example is called “Active – Coloured” Open the view using SharePoint Designer. Right click on the List View Web Part and select “Convert to XSL Data View”. This will automatically convert settings for the current view into da