Microsoft Office Tutorials and References
In Depth Information
Chapter 14: Building Custom Solutions
6. Create a string and initialize it with the workbook to be opened by the API:
string xlWorkbookPath =
7. Create and initialize additional strings to capture the UI culture and the data culture:
string uiCultureName = “en-US”;
string dataCultureName = “en-US”;
Add the API OpenWorkbook method call to have the ECS open the workbook and return a
xlSessionId = xlEcsApi.OpenWorkbook(
out xlStatus);
Add the API CloseWorkbook method call to close the workbook and end the session:
xlStatus = xlEcsApi.CloseWorkbook(xlSessionId);
Complete the try block by adding the following catch block for SOAP exceptions:
catch (SoapException soapE)
Console.WriteLine(“Soap Fault: {0}”, soapE.Message);
Following is the complete solution. This sample represents a starting point for trying the API. In the
spirit of reducing the size of the sample, many good coding practices have been overlooked. Return
values are not validated, error handlers are not present, and a number of values are hard-coded, to
name a few of the shortcuts used here.
using System;
using System.Collections.Generic;
using System.Text;
using xlWebService.ExcelWebService;
using System.Web.Services.Protocols;
namespace xlWebService
class Program
static void Main(string[] args)
ExcelService xlEcsApi = new ExcelService();
xlEcsApi.Credentials = System.Net.CredentialCache.DefaultCredentials;
Status[] xlStatus;
string xlSessionId = “”;
Search JabSto ::

Custom Search