Microsoft Office Tutorials and References
In Depth Information
as you’ve seen, this functionality is built to retrieve information from an excel workbook. let’s now extend the
functionality and write to this excel file.
Copy and paste the following code toward the end of previously added code under the
GetData method:
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));
press F5. view the output, and notice that the code first performs a read operation on the
workbook and then a write operation. Finally, the updated rows are retrieved and displayed
as shown in Figure 5-25 .
Figure 5-25. Displaying both read and write capabilities in an Excel workbook output using SOAP and Excel Services
instead of impersonating the user, you can also submit user credentials (Network) for
authentication, like so:
es.ClientCredentials.Windows.ClientCredential =
new System.Net.NetworkCredential("UserName", "Password", "Domain");
the final logic looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ES_Soap.ExcelService;
Search JabSto ::

Custom Search