Notes:
When using the Excel Services web services interface application, you must first reference the Excel Web Services in the project, and then add
The Web services of this Excel service can be searched locally on the server!
You can directly access the Excel file in the document library through the Excel Services web services interface and transfer the file or return the data. Why do you want to use the Excel Services web services interface ?, Sometimes, in actual applications, some Excel files do not want to publish all the data, and some data is confidential. Therefore, you can use the web services interface of Excel services to control permissions. through the Web Services interface of Excel services, we can operate through our webapp program to make more user-friendly programs.
The test code is as follows:
Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Namespace exceldemo
{
Public partial class excelusercontrol: system. Web. UI. usercontrol
{
Protected void page_load (Object sender, eventargs E)
{
}
Protected void btnsum_click (Object sender, eventargs E)
{
Localhost. status [] status;
String sessionid = NULL;
Localhost. excelservice es = new exceldemo. localhost. excelservice ();
// Set verification information
Es. Credentials = system. net. credentialcache. defaultcredentials;
// Start accessing a session
Try
{
Sessionid = es. openworkbook ("http: // WH/sites/report/exceldocument/sheet.xlsx", String. Empty, String. Empty, out status );
}
Catch
{
Sessionid = NULL;
}
// Set parameters
If (sessionid! = NULL)
{
Es. setcella1 (sessionid, "sheet2", "employee", tbemployee. Text. Trim ());
Es. setcella1 (sessionid, "sheet2", "saler", tbsaler. Text. Trim ());
}
// Retrieve the result
Object payment = es. getcella1 (sessionid, "sheet2", "B3", true, out status );
If (payment! = NULL)
{
Lbsum. Text = convert. tostring (payment );
}
Status = es. closeworkbook (sessionid );
}
}
}
Simple demo download:/files/wanghao-3/exceldemo.rar
The code is not the end, but I am learning to use it!