承接MOSS各种工作流开发 联系人:王先生.电话:13691349686 QQ:252385878 MSN:wanghao-3@hotmail.com

寻找统一通讯产品代理商(运营平台上的模块包括:网上客服、企业电视台、视频会议、远程教育培训、voip等。所有模块均可单独租用。 联系人:张小姐 电话:13522877350 QQ:419919940

Excel Services 的 web Services 接口应用




  笔记:
     使用 Excel Services 的 web Services 接口应用,当时首先需要在工程里面引用这个excel这个web services ,然后在工程里面添加

这个Excel Services 的 web Services 可以直接在服务器的本地查找就可以!

直接通过 Excel Services 的 web Services 接口 直接访问文档库里面的excel,并传递传送,或者数据还回结果.大家问我们为什么要使用这个Excel Services 的 web Services 接口?,因为有时候我们在实际的应用中,有些excel不想公布全部数据,有些数据是保密的,所以通过Excel Services 的 web Services 接口 可以很好的控制权限.通过Excel Services 的 web Services 接口来操作,可以通过我们webApp程序来操作,可以做出更人性化的程序.

测试代码如下:


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();


            //设置验证信息
            es.Credentials = System.Net.CredentialCache.DefaultCredentials;
            //开始访问一个session
            try
            {
                SessionId = es.OpenWorkbook("http://wh/sites/report/ExcelDocument/sheet.xlsx", string.Empty, string.Empty,out status);
            }
            catch
            {
                SessionId = null;
            }

            //设置参数
            if (SessionId != null)
            {
                es.SetCellA1(SessionId, "sheet2", "employee", tbEmployee.Text.Trim());
                es.SetCellA1(SessionId,"sheet2","saler",tbSaler.Text.Trim());

            }
            //取回结果
            object payment = es.GetCellA1(SessionId, "sheet2", "B3", true,out status);

            if (payment != null)
            {
                lbSUM.Text = Convert.ToString(payment);
            }

            status = es.CloseWorkbook(SessionId);

 

        }
    }
}


简单demo下载:/Files/wanghao-3/ExcelDemo.rar
代码不是最后,只是本人学习用!

posted on 2007-12-16 19:44 A A 阅读(237) 评论(1)  编辑 收藏 所属分类: SharePoint


标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      


相关链接: