Microsoft Office Tutorials and References
In Depth Information
using System.Web.Services.Protocols;
namespace ES_Soap
{
class Program
{
static string sheet = "Sheet1";
static string excelFilePath = "http://<site>/<doc lib>/<excelfile>.xlsx";
static void Main(string[] args)
{
GetData();
}
static void GetData()
{
ExcelService.ExcelServiceSoapClient es = new ExcelService.ExcelServiceSoapClient();
es.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
//es.ClientCredentials.Windows.ClientCredential =
new System.Net.NetworkCredential("UserName", "Password", "Domain");
Status[] status;
RangeCoordinates rangeCoordinates = new RangeCoordinates();
try
{
string session = es.OpenWorkbook(excelFilePath, "en-US", "en-US", out status);
for (int i = 3; i <= 13; i++)
{
Console.WriteLine("Remaining hours for the task " +
es.GetCell(session, sheet, i, 5, false, out status) + " is: " +
es.GetCell(session, sheet, i, 12, false, out status));
}
Console.WriteLine();
Console.WriteLine(
"----------- WRITE & READ NEW VALUES TO/FROM EXCEL WORKBOOK -----------");
es.SetCell(session, sheet, 14, 5, "New Task for Srini"); // Assign new task to Srini
es.SetCell(session, sheet, 14, 12, "8"); // Assign estimated hours as 8 for the task
Console.WriteLine("Remaining hours for the task " +
es.GetCell(session, sheet, 14, 5, false, out status) + " is: " +
es.GetCell(session, sheet, 14, 12, false, out status));
Console.Read();
}
catch (SoapException soapException)
{
Console.WriteLine(soapException.Message);
}
}
}
}
So far, the data we’ve been using has been quite simple. however, with excel you can connect and integrate with huge
data sources, such as Olap databases. You can even use cube data in excel with very little configuration and the default
settings. let’s see how to connect with multidimensional data sources and gain some insights into using excel Services.
Search JabSto ::




Custom Search