First "Hello World" code sample with the Excel Services APIs!

Welcome to the new world of Excel Services in the Microsoft Office Sharepoint Server 2007 product line! During the next few months, I will be exploring the various programmability capabilities of Excel Services.


On this first post of many, we will make our first “Hello World” application that uses Excel Services to execute Excel 2007 Workbooks on the server. I will be using Visual Studio 2005 throughout my samples, but any language or tool that supports consuming web services will be able to achieve the same results.


Note that for the most part, my examples will be in C# - I will try to include VB.NET samples for most of these posts though. I will post the VB.NET equivalent of the sample in this post next monday.

Preparing the workbook for the sample

To begin, we will need a workbook. This will be our Hello World workbook and will contain a single cell (A1 of course) that contains the following:

A1: Hello

A2: Excel 2003

A3: =Concatenate(A1, " ", A2)


After creating this workbook, save it to your favorite Sharepoint Library or UNC and make sure Excel Services is aware of that location in its Trusted Locations list.

Creating the form and importing Excel Services API

Next, we will create a sample Win-Forms applications that will contain a single text-box control and two buttons. We will set the text on one button as “Get Default” and call it getDefaultButton and set the text on the other to be “Get Correct” and set the name to be getCorrectButton.


Our sample application will get the value in A3 when the getDefaultButton is pressed. However, when the getCorrectButton is pressed, it will change the value in A2 to the correct version of Excel and get the recalculated value in A3 (which will hopefully be “Hello Excel 2007”).


The last part of the needed preparation is to import the Excel Services API into our Visual Studio 2005 project. To do that, we will go to the Project/Add Web Services menu option. In the dialog that opens up, in the address text box we will enter:

http://<sharepoint server name>/_vti_bin/ExcelService.asmx?wsdl

Also, in the Web Service Name we will enter “ES” – this will be our namespace for all things Excel Services API from now on.

Finally, writing code to get information from Excel Services

Next, we are going to implement the code behind the Get Default button. The first step is to actually create the proxy object. We will place that object inside a using() statement since it implements the IDisposable pattern (note that neither the generated proxy class nor any of the classes it derives from actually do any real work in their dispose, but since the base class Component has a Finalizer, we will incur some unneeded perf degredation if we don’t dispose):


using (ES.ExcelService excelService = new ES.ExcelService())


       excelService.Credentials = System.Net.CredentialCache.DefaultCredentials;



So far so good – we created the proxy instance. This instance will allow us to actually make calls into Excel Services. Note that we set the credentials to be those of the user that is currently logged on to the machine – if we don’t do that, there’s a good chance the web server will deny us access to the web-service.


Next we will call into the server, requesting that it opens the workbook we saved. We will do that by calling into the OpenWorkbook() method. This method will try to open the workbook on the server – if it succeeds, it will return a session id that we will use to continue the communication with the server. The other parameters this method takes are the locales to use (I am leaving these empty for now – more on those at a later blog) and an out parameter that will contain status information on the operation (more on that in a later post as well):


using (ES.ExcelService excelService = new ES.ExcelService())


       excelService.Credentials = System.Net.CredentialCache.DefaultCredentials;

       ES.Status[] stati;

       string sessionId = excelService.OpenWorkbook(

              "http://MyServerName/Shared Documents/HelloWorld.xlsx",

              String.Empty, String.Empty, out stati);



If our call did not fail, it means we have a workbook waiting for us on the server. Next, we will get the value from cell A3 (the one that contains the formula). For that, we will add the following code below the OpenWorkbook() call:


       object o = excelService.GetCellA1(sessionId,




              out stati);


As you can see, we pass the session id we got from the OpenWorkbook() call into the GetCellA1() call (the A1 in the name of the method denotes the way the method works – it can be used to get any cell from the workbook) – almost all the methods on the Excel web service require this first parameter. The second and third parameters are used to tell Excel Services what part of the workbook we want. In this case, we want cell A3 in Sheet1. The Boolean we pass as the fourth parameter tells Excel Services if we want the data returning to be formatted or not . The last parameter is the status array.  More on those parameters and on the various ways to get data from Excel Services in a future post.


The local variable o should now hold the string “Hello Excel 2003”.  There are two more things we need to do before we finish with this phase. The first is to place the value we got from the cell into the text box and the other is to close the workbook we opened. Note that Excel Services will timeout workbooks that are left opened on the server. To minimize wasted resources, it is advised that you close a workbook you are done with. So the final code will look like this:


using (ES.ExcelService excelService = new ES.ExcelService())


       excelService.Credentials = System.Net.CredentialCache.DefaultCredentials;

       ES.Status[] stati;

       string sessionId = excelService.OpenWorkbook(

              "http://MyServerName/Shared Documents/HelloWorld.xlsx",

              String.Empty, String.Empty, out stati);


       object o = excelService.GetCellA1(sessionId,




              out stati);


       textBox1.Text = (string)o;





If you run your program now and click the Get Default button, you should get the “Hello Excel 2003” appear in the textbox.

Writing data back to Excel Services

We will now add code to the other button. Feel free to copy and paste the code we wrote for the first one into the Click event of the second one – we will just be adding code.


For this second example, we will write the value “Excel 2007” into the A2 cell – if everything works right, and you get the value from A3 (after setting the value in A2 of course), you should see the text “Hello Excel 2007” in the cell, instead of the default one in the saved workbook. For that, we will add a call to SetCellA1()  into the code we copied from the Get Default button, right before we call GetCellA1():


excelService.SetCellA1(sessionId, "Sheet1",

       "A2", "Excel 2007");


That’s it! If you now run your sample and click the “Get Correct” button, you should see “Hello Excel 2007” in the textbox!

So what did we learn?

  • We now know how to add a web reference to Excel Services so that we can use it in our program.
  • We used the OpenWorkbook() method to open a workbook on the server.
  • Calling the SetCellA1() method allows us to manipulate the workbook that’s opened inside the session OpenWorkbook() gave us.
  • To get data from the workbook, we can call the GetCellA1() method.
  • When we are done with our session, we can call the CloseWorkbook() method.

 Note about the attached sample: You will need to change the name of the workbook constant at the top of the Form1 class to work with the name of your workbook. You will also need to change the ES web service properties to point to the server that hosts your Excel Services.

Comments (88)

  1. For those of you interested in programming Excel Services, check out this blog.

    One of the developers…

  2. Paolo says:

    Thank you for this nice code preview.

    (Just a linguistic note: the plural of Latin word "status" is "status" (4th declension, not 2nd declension) ;-).

  3. Shahar Prish says:

    But it’s not as funny. 🙂

  4. Excel Services does not support External Workbook References. I show how you can use a UDF to get similar functionality.

  5. Durante la preparaci&#243;n de las sesiones para el evento DevDays Andino 2006, cuyos temas principales fueron…

  6. Prasad says:

    I copied the assemblies Microsoft.Office.Excel.Server.WebServices and Microsoft.SharePoint to my pc from the maching where Office Server is installed.I added the references to these in my console application.But at runtime it throws an error at the line where i am instantiating the ExcelService class saying that it could not load the assembly Microsoft.Office.Excel.Server.Is there any assembly by this name?

  7. Shahar Prish says:


    Read the part in the article about "Creating the form and importing Excel Services API". You dont need to copy these assemblies – just use VS to create a proxy to the web-services.

  8. Prasad says:

    Hi Shahar

    I have added the Web Refernece of the ExcelService web service in my console application.However I dont find any class by the name ExcelService in the instantiated proxy class.Instead I find the class ExcelServiceSoap.Although this contains a method called OpenWorkBook,the signature of the method is entirely different from what is given above eg and also in the msdn example which corresponds to the ExcelService class in the assembly Microsoft.Office.Excel.Server.WebServices.

  9. Prasad says:

    Moreover I am using Office Server 2007 Beta 2.

  10. Prasad says:


    I realized my mistake.I had put the reference of the ExcelCalculation Server/ExcelService.asmx in my console application.

  11. KieuAnh says:

    I need comment code

  12. Shahar Prish says:


    Not sure what it is you want. Can you elaborate?

  13. cheeso says:

    A related post – this one shows a Java application connecting with Excel Services via the web service interface.  -Dino

  14. Martin Parry says:

    This post is a list of useful resources for developers working with the 2007 Microsoft Office&amp;nbsp;System…

  15. Tyler says:


    Can you comment if the CalculateA1 function is working.  I have a namedrange cell with a Rand() function in it.  When I open the workbook and try to CalculateA1 the cell with the rand() function it doesnt seem to update.  Any ideas?   I am not running the tech refresh.

  16. Shahar Prish says:


    The reason you are not seeing anything change is that Excel Services optimizes the recalculation – it will not let a user recalc more than once per 5 minutes. This is configurable inside the Trusted Location – there’s a setting called "Volatile function lifetime" or something similar that you can use to adjust the 5min. Setting it to zero will make it so that every recalc will realy recalc. Note that reducing this setting will impact performance as it will require Excel Services to recalculate more often.

    In B2TR, there’s a slight change (as far as I remember) – a manual recalc will ignore the volatile cache time and actually do a recalc.

  17. Instead of re-hashing information I’ve found elsewhere I figured a pre-reqs post would be good.


  18. Instead of re-hashing information I’ve found elsewhere I figured a pre-reqs post would be good. One of

  19. replytojain says:

    A very neatly explained example.

    Great work!!!

  20. Amarnath reddy says:


    I have tryied this example.Iam able to gat the data from the excel but unable to write the data into the excel by using  "SetCellA1" property.

    anyone can help on this.



  21. Shahar Prish says:

    What error are you getting? Can you share the code you are running?

  22. Amarnath reddy says:

    Hi Shahar,

    Iam not getting any error.i folowed the same steps which u have given.

    this is the code which iam writing data into the excel which is in Sharepoint server 2007 using excel webservices.



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


               Dim mystat() As MyExcelWebReference.Status

               Dim targetpath As String

             Using es As New MyExcelWebReference.ExcelService()

                targetpath = "http://SharepointServer/ExcelServices/Amar/Shared%20Documents/Amar.xlsx&quot;

                   es.PreAuthenticate = True

                   es.Credentials = System.Net.CredentialCache.DefaultCredentials

                   sessionid = es.OpenWorkbook(targetpath, String.Empty, String.Empty, status)

                   If (sessionid = "") Then

                       MsgBox("Error in Opening Workbook")


                       es.SetCellA1(sessionid, "Sheet1", "A1", "Amar")

                   End If


                End Using

           Catch ex As Exception


           End Try

       End Sub


    End Code

    Please look into this and give me the code sample.



  23. Shahar Prish says:


    Are you expecting to see the value change inside the Excel workbook inside sharepoint?

  24. Amarnath Reddy says:

    Hi Shahar,

    Thanks for the fast response…

    yes i want to write some data into the excel located in the share point server 2007.

    can you give me the points.



  25. Shahar Prish says:

    Ezcel Services is not an authoring environment. It was not meant in this version to "Save Back" to the SP server.

    It’s still possible, but requires a few more steps.

    1. Call the GetWorkbook() method on the proxy to get back a byte array represnting your workbook.

    2. Use the SharePoint OM to save that byte array back to the server.

  26. Amarnath reddy says:

    Thanks Shahar,

    please can you give me the sample code steps for this.

    once again thanks for the response.



  27. Shahar Prish says:

    I can, but it may actually take me a little while to do this. Don’t have time for posting articles right now and while it’s not complex, it’s a fair amount of code.

    Until I get to do it, I suggest you search for information on how to use the SPFile.SaveBinary() method and take a look at the GetWorkbook() method of Excel Services.


  28. AmarnathReddy says:

    Thanks for the info..

    I will check the details…



  29. Amarnath Reddy says:

    Hi All,

    I need some syntax to know the Active excelsheet name which i have opened using excel webservices.

    please give me the code samples for that.

    i want to see the active sheet neme when i open the excel in "view in browser" option in sharepoint server.

  30. Shahar Prish says:

    Can you elaborate on "i  want to see the active sheet neme when i open the excel in "view in browser" option in sharepoint server"?

    Not sure I undestand what you mean.


  31. Amarnath Reddy says:

    Hi Shahar,

    I have published my excel sheet into the sharepoint server 2007.

    in that sheet in one cell i have placed one formula(i.e udf function) to get the activesheet name.

    now when i want to go and see the excel in "view in browser" option in Sharepoint server 2007t then i want to get the active sheet name in the given cell whare i have given the formaula.

    please help me out on this.



  32. Shahar Prish says:

    What is the UDF that returns the ActiveSheet name exactly? I wasn’t aware that we supported something like that.

    (Which, of course, does not mean much, since there are many Excel functions I am not aware of. :))


  33. Amarnath Reddy says:

    Hi Shahar,

    I need one excel inbuilt funtion to get the Activesheet name.

    that only i want to write in the UDF to get the Active sheet name.



  34. Shahar Prish says:

    There is no such feature.

  35. Shahar Prish says:

    Can you explain what you need it for? It may help us in a future release.

  36. Amarnath Reddy says:

    Hi Shahar,




  37. Anirudh says:


    I used the information in this blog to work with the excel services API within MOSS 2007 and was able to do a variety of activities with the exposed web service.

    I am trying to access the same web service from a RTM Project Server website. The website exposes the particular webservice but I cannot add the reference itself. The Add Reference button is disabled and I get the following error messages:


    The document at the url http://litware:104/_vti_bin/ExcelService.asmx?wsdl was not recognized as a known document type.

    The error message from each known type may help you fix the problem:

    – Report from ‘DISCO Document’ is ‘Root element is missing.’.

    – Report from ‘WSDL Document’ is ‘There is an error in XML document (0, 0).’.

    – Root element is missing.

    – Report from ‘XML Schema’ is ‘Root element is missing.’.


    Is this an issue specific to Project Server RTM?

    I then tried to access the excelservice webservice(the wsdl) of a RTM MOSS 2007 website and got the following error:


    Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘EnvDTE.IVsExtensibility’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{3C536122-57B1-46DE-AB34-ACC524140093}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).


    When I tried to add this webservice it allowed me but w/o the wsdl document.

    I’ve never faced such problems with the Beta2 versions of MOSS.

    I haven’t found any info on these issues elsewhere and so any help would be appreciated.

  38. Vandana says:

    How does a workflow work in Excel services?Basically i would like to know how the excel workbooks published on to the server behave when a workflow is  started.Will the documents be visible to particular user only after it is approved by the initiatir or some other approver?



  39. Shahar Prish says:


    As for the first question: Excel Services is only enabled on the Enterprise version of MOSS. As far as I know, Project server is a different SKU that does not support it.

    For more help on that, you can try accessing the forums:

    As for the second question: What is it that you are doing exactly when you say "I then tried to access the excelservice webservice of a RTM MOSS 2007 website"? Where do you get that COM error you describe?

  40. Shahar Prish says:


    It all depends on what workflow you apply to the document library in question. There is no inherent process that happens for Workbooks on the server.

  41. Vandana says:


    Thanks for the reply.I need bit more clarification on workflows.

    I have used approval workflow which routes the documenst thru all the workflow participants.

    whai i feel is once a document is approved then only it should go to next level for further processing.

    but i find no such restriction in excel services.Is there any  locking mechanism either thru custom workfkows or with predefined workflows wherein a workbook is viewed only if it approved by a particular user?



  42. Anirudh says:

    Hi Shahar,

    First off thanks for the prompt reply!


    Well its a disappointment if exceservices is not supported for project server, because even the project web access websites created under Project Server offer that excelservice webservice,i.e. you can see it when you try to add the web reference.

    However it doesn’t let you add this reference(button disabled) and the errors are printed in the web service despcrription txtbox.


    The document at the url http://litware:104/_vti_bin/ExcelService.asmx?wsdl was not recognized as a known document type.

    The error message from each known type may help you fix the problem:

    – Report from ‘DISCO Document’ is ‘Root element is missing.’.

    – Report from ‘WSDL Document’ is ‘There is an error in XML document (0, 0).’.

    – Root element is missing.

    – Report from ‘XML Schema’ is ‘Root element is missing.’.


    After that I tried to access a webservice of a MOSS RTM site (on the same machine) and got the COM error.I got a workaround for that(it was a site specific error)

    That was not the main issue; I really needed the excelserviceAPI for Project server. Are you sure it is not supported?


  43. Shahar Prish says:


    I am double-checking. But I think Excel Services comes only as part of the enterprise version.


    I sent an email in the internal alias to see if something comes up.


    Consider using the Excel Services forums ( for questions such as this – you will get more eyes on them.

  44. Shahar Prish says:


    Excel Services only comes as part of the MOSS for Internet Sites or the Enterprise packages. For more info, please follow this link:

  45. Amarnath Reddy says:

    Hi All,

    I have created a approval workflow and i have added approvers name as administrator,spuser1 and i have assighned the work flow to the test document.after that i have loged in to the sharepoint server as another user.when i want to open the test document without approving the document logedin user able to open and edit the document but it should display some type of message like "it is not yet approved by the administrator workflow is in process".

    is there any locking is available for the document when workflow is processing.

    please anybody can give the flow of the work flow and approval steps and workflow conifiguration.



  46. Amarnath Reddy says:

    Hi All,

    I want to know how to auto schdule my excel files in sharepoint server there any provision given by sharepoint server 2007 to schdule the files and also programatically how can set the schduler.In sharepoint there is one dll i.e Microsoft.SharePoint.SPSchedule

    how can we work on this iam not clear.can anybody can send sample code and help on this.



  47. Shahar Prish says:

    Can you explain what "Auto Scheduling" means? What’s the expected behavior? What do you want them to auto schecule to?

  48. Sasya says:

    Hi Sahar,

    While opening the workbook I am getting "The file that you selected could not be found. Check the spelling of the file name and verify that the location is correct" error, but the path of the excel that I am giving is correct. How can I resolve this.

    Can we refresh the document that is stored in Sharepoint under Excel trusted Location by calling Refresh method that is available with Excel services workbook? Is this possible?

  49. Sasya says:

    I am getting the Error while opening the workbook, error is "You do not have permissions to open this file on Excel Services." The excel file that I am opening is in trusted location in sharepoint. Do we need to give any permissions to that document in sharepoint document library.

    How do I can resolve this?

    Here is the full code

          ExcelService currentService = new ExcelService();

           string targetPath = "http://localhost/Documents/TestDoc.xlsx&quot;;            

           Status[] outStatus;

           currentService.Credentials = System.Net.CredentialCache.DefaultCredentials;

           string sessionId = currentService.OpenWorkbook(targetPath, "en-US", "en-US", out outStatus);

    Thanks in Advance,


  50. Shahar Prish says:

    Can you choose "View in WebBrowser" in the drop down on the file?

  51. Sasya says:

    View in WebBrowser" in the drop down on the file is working from Sharepoint document library.

    But I am getting the error while accessing using Excel web services.

    How do I resolve this error?



  52. Sasya says:

    The excel sheet that I am trying to access from Excel Service also has Data Connections, which are used to pull data from database(SQL server).



  53. Sasya says:


    I am using Excel services for refreshing the excel sheet and then trying to save refreshed document to the Sharepoint library.Below is the thing that I am trying out:

    1. Opening the workbook from Sharepoint trusted location.

    2. Refreshing the excel report(Has Pivot Tables and Pivot Charts).

    3. Writing refreshed data to an external file.

    Here is the code:

           ExcelService currentService = new ExcelService();

           string targetPath = "http://localhost/Documents/EmpDept.xlsx&quot;;

           Status[] outStatus;

           currentService.Credentials = System.Net.CredentialCache.DefaultCredentials;

            string sessionId = currentService.OpenWorkbook(targetPath, "en-US", "en-US", out outStatus);

           currentService.Refresh(sessionId, "Employees");

           byte[] contents = currentService.GetWorkbook(sessionId, WorkbookType.FullWorkbook, out outStatus);

    using (BinaryWriter binWriter =

           new BinaryWriter(File.Open(@"C:Test.xlsx", FileMode.Create)))





    I have modified my data source by adding new records,

    But even after the refresh also the excel report is not getting refreshed. When I check Text.xls it is as same as the Source excel and not updated with the latest data from data source.

    When I refreh the Connection from Excel the sheet is getting refreshed with the latest data from my datasource.

    Is there anything I am missing here?

    Any help will be appreciated.



  54. Shahar Prish says:


    RE: Failure of EWA

    What’s the error you are saying?

    RE: Api question.

    Hmm. That’s very strange.

    1. What does the connection shunt information to? (PivotTable?)

    2. What happens if you call .RefreshAll() instead of .Refresh()?


  55. Sasya says:

    Thanks for the response,

    ConnectionString Info:

    Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=SolutionMetaData;Data Source=xxxx;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=Test;Use Encryption for Data=False;Tag with column collation when possible=False



    From C# Code for Excel Services:

    If I call .Refresh by passing in second parameter as empty then it will refresh all the connections(Source:MSDN) I have tried the one below, but still it doesn’t refresh.

    currentService.Refresh(sessionId, "");

    If I am refreshing the report from Excel client by using Refresh or RefreshAll from Connections Tab I am able to see the updated report in excel. But which is not happening from Excel web services.



  56. SL says:

    I have a problem opening a workbook from a remote machine using Excel web services.

    I am getting the following error:

    URL authorization failed for the request

    I am using the default credentials for Excel web services in code.

    from X machine I am calling openworkbok for the url on machine MySite

    URL passed in as parameter for OpenWorkBook is :http://MySite/Reports/Salaries.xlsx

    Thanks in advance


  57. SL says:

    If I try to access the url http://MySite/_vti_bin/ExcelServices.asmx I am getting the error from machine x as well as machine Mysite, and Just it is displaying that an Error has occurred.

    In eventViewer I didnt see any message related to that.

    But on Mysite I can view http://MySite/Reports/Salaries.xlsx without any error in WebBrowser by clicking View in WebBrowser link in the dropdown in Document library.

    But If I am accessing ExcelServices.asmx on MySite machine with http://localhost/_vti_bin/ExcelServices.asmx, I am able to access it without any error.

    And in IIS for Office Server Web Services is configured with both Annonymous and Windows authentication.

    MySite/_vti_bin/ExcelServices.asmx is also configured with both Annonymous and Windows authentication.



  58. Sasya says:


            I have strucked with the Data refresh problem using Excel services using C# code. It is not working as documented in MSDN if my document has data connections to external data sources.

    Thanks in Advance,


  59. Shahar Prish says:


    If you choose the "Refresh All Connections" from the  EWA toolbar does it work?

    (So, load the file in EWA and select the "Refresh ALL" and see if you get the new information you expect).

  60. Ira Levin says:


    Excel Services API isn’t accessible to anonymuos users, so you either must authenticate by supplying a network credentials (e.g. CredentialsCache.DefaultCredentials), or if you’d like you can modify the permissions of the anonymous user so that it has the "UseRemoteApi" permission. You can alter the permissions of the anonymous user from OM, or you can grant anonymous users full access to websites.

    I hope this helps.

  61. SL says:

    Hi Levin,

    Here is the code that I am using:

    ExcelService currentService = new ExcelService();

           string targetPath = "http://MySite/Reports/Salaries.xlsx&quot;;

           Status[] outStatus;

           currentService.Credentials = System.Net.CredentialCache.DefaultCredentials;

           string sessionId = currentService.OpenWorkbook(targetPath, "en-US", "en-US", out outStatus);

           currentService.Refresh(sessionId, "");

           byte[] contents = currentService.GetWorkbook(sessionId, WorkbookType.FullWorkbook, out outStatus);

    In my code I am using CredentialsCache.DefaultCredentials, but still OpenWorkBook is throwing out an error. And annonymous access in IIS is configured with Service account.

    And I have tried running this code from the machine MySite, I am still getting the error.



  62. Majeti says:

    Hi Anirudh,

    if you have created a site collection then use the url reference as:




  63. Sush says:

    Hi All,

    I have deployed a web application which uses excel web service on a sharepoint site. I have some named items on the excel sheet. How can i programatically get the list of all the named items/parameters defined in there.



  64. Shahar Prish says:

    You cannot. The only workarounds you have available (afaik) are:

    1. Know the names before hand.

    2. Place the names in a hidden sheet and have a well known range name for the range that contains all the named ranges. Then use that to get the names.

  65. Frank van de Groep says:

    Hi there,

    My project/app is called Webexcel1. I added a webreference called ES. But it doesn’t recognize the namespace ES.

    I tried it with the first using and the second one.

    //using Webexcel1.ES;

    using System.Web.Services.Protocols;

    using (ES.ExcelService excelService = new ES.ExcelService())


          excelService.Credentials = System.Net.CredentialCache.DefaultCredentials;




  66. frankjnf says:

    Already solved my problem. It was due to a lack of knowledge in VS. I had the using declarations in the wrong spot of my project. Basics….

    Works fine now.

    Thanks and good luck.

  67. Sachin Vyas says:

    Thanks for nice article.

    But i am getting an Soap Exception error "An error has occured" message. in foolowing line

    string test = es.OpenWorkbook(targetWorkbookPath, "en-US", "en-US", out outStatus);

    can anyone help me why i am getting this exception and how i can solved it.

    Thanks in advance.

  68. thana says:


    my servlet return excel file i am getting excel file for java script request,but let me know how do open or display excel file through ajax responseText



  69. Shahar Prish says:

    That’s not something you can do today.

    The only thing you can do is use AJAX to get data from Excel Services.

  70. VVS says:

    is it necessary to install office 2007 and devloper’s machine or they can access from share point server. if Office 2003 is present on the local system

    what are the minimum requirements for developer machine

    if share point server machine has share point 2007 and excel 2007

  71. Shahar Prish says:

    You dont need anything installed on the Developer machine – just a connection to the Excel Services SharePoint.

  72. Jason says:

    I’m running into a soap exception error that a few of you mentioned previously. I get a "You do not have permissions to open this file on Excel Servcies" error when on the line of code where the ExcelService.OpenWorkbook function is called. I’m passing into the function the default credentials and a valid location. I’ve added the location of the xlsx workbook as a trusted WSS file location but i still get this error. I’d like to know if there are any possible explanations for this error. Thanks in advance guys.

  73. Shahar Prish says:

    Can you open the file via EWA?

    When you run into issues like that, that’s the first thing you should check – that will tell you whether the issue is with the server or with your software.

  74. Jason says:

    I can open it via EWA. Sorry bout leaving that part out before. I’m thinking it might have something to do with either the default credentials I’m passing into the function. Or that it has to do with the workbook location. The workbook is located in a content database path (http://servername/site/subsite/filename.xlsx).

  75. Phaneendra says:

    Can i set security on Sheet level in a published workbook in Excel Services? My intension to publish a workbook with four sheets( i.e. user1,user2,user3,Admin). Every user have only access to his/her sheet only.

    But Admin can view all sheets as well as by using excel built-in formulas he can go for some calculations by taking input from some/all other user sheets information.

    Does it possible in Excel Services?

  76. Shahar Prish says:


    If your user can open it in a browser, they should be able to open it through the API. What type of application is this?


    We do not support this level of granularity with security – sorry.

  77. Anshuman says:

    I am facing a similar kind of issue regarding SOAP exception at OpenWorkBook method.

    i am able to open the sheet in browser, i.e. it is working fine in EWA, but  not coming up using web service.

    I have checked that the workbook is stored at the trusted location. also I have checked the permission of the user. It’s not working even by providing the Full Control.

    What else could be the possible reason for this SOAP Exception?

  78. Shahar Prish says:

    Can you paste the skeleton of your code (everything relevant up to and including the OpenWorkbook call)?

  79. Anshuman says:

    Here is that snippet of code:

    private void button1_Click(object sender, EventArgs e)


               ExcelService proxyService = new ExcelService();

               proxyService.SoapVersion = SoapProtocolVersion.Soap12;

               proxyService.Credentials = System.Net.CredentialCache.DefaultCredentials;

               Status[] status = null;

               string SessionId = null;

               string pathWorkbook = "http://litwaredemo:13300/sites/mysitecollection/ExcelWorkBooks/Calculator.xlsx&quot;;

               SessionId = proxyService.OpenWorkbook(pathWorkbook, String.Empty, String.Empty, out status);

               status = proxyService.SetCellA1(SessionId, "Calculator", "Loan", textBox1.Text);

               status = proxyService.SetCellA1(SessionId, "Calculator", "Rate", textBox2.Text);

               status = proxyService.SetCellA1(SessionId, "Calculator", "Years", textBox3.Text);

               status = proxyService.CalculateWorkbook(SessionId, CalculateType.CalculateFull);

               object result = null;

               result = proxyService.GetCellA1(SessionId, "Calculator", "Payment", true, out status);

               if (result != null)

                   textBox4.Text = result.ToString();



    Its just a small application for calculation.

    SessionId = proxyService.OpenWorkbook(pathWorkbook, String.Empty, String.Empty, out status);

    this line of code is throwing the SOAP exception.

  80. Satish says:

    hey guys i have s problem……..

    While using UDF’s i get the return values in a data table.

    Now i wannt to show this entire table in the excle sheet as it is.

    How can I do that?

  81. Shahar Prish says:

    Can you further explain what the issue is?

    what do you mean by Data table? What tdo you mean "as it is"?

  82. Sanjay says:


    The OpenWorkbook() is throwing the following exception:

    "Excel Web Services could not determine the Windows SharePoint Services site context of the calling process"

    Please note:

    1> I’m using Excel Web Reference not static binding

    2> The excel file is in trusted location.

    3> I’m able to browse the excel file using IE.

    Please let me know what colud be the problem?

  83. Kiran Reddy says:

    Hi Sahar,

    This is kiran reddy. i Want to know how to convert  excel data in Visual Basic code language

  84. Shahar Prish says:

    Not sure I understand the question, Kiran.

  85. kiran reddy says:

    how to learn visual basic through online? is there anybody to teach VB

  86. rain says:

    how to learn visual basic through online? is there anybody to teach VB

Skip to main content