Excel Services web services interface application

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.