首页 »办公软件 » 一步一步sharepoint:一步一步SharePoint 2007的 4十 8:实现Excel Service(3)——调用Excel Service »正文
一步一步sharepoint:一步一步SharePoint 2007的 4十 8:实现Excel Service(3)——调用Excel Service
来源: 发布时间:星期日, 2009年2月8日 浏览:37次 评论:0
本文举例源代码或素材下载
摘要 本篇文章将介绍实现Excel Service 最后 部分—— Excel Service 正文 下面将记录每 步 操作过程 1、首先打开Visual Studio 2005 创建 个ASP.NET Web Application项目 2、创建好 项目就是这个样子 3、在Visual Studio 2005 菜单中依次选择Project Add Web Reference 并单击该菜单项 4、在弹出 Add Web Reference页面中 在URL文本框中输入上 篇文章中访问过 Web Service 网址:http://denny:9001/sites/Wodeweb/Docs/ExcelServices/_vti_bin/ExcelService.asmx 并在Web reference name文本框中输入 个名字 然后单击Add Reference按钮 5、添加完Web Reference后 项目就是这样 了
6、打开Default.aspx页面 设计试图 并按照图中 样子在该页面上添加几个Label框、TextBox框和Button按钮 并分别命名 7、双击Button按钮 即可进入编写代码 试图 我们将代码更改为如下 代码: 1using ; 2using .Data; 3using .Configuration; 4using .Collections; 5using .Web; 6using .Web.Security; 7using .Web.UI; 8using .Web.UI.WebControls; 9using .Web.UI.WebControls.WebParts; 10using .Web.UI.HtmlControls; 11 12using .Net; 13 14using Eallies.ExcelServices.Demo.WebService; 15 16 Eallies.ExcelServices.Demo 17{ 18 public partial _Default : .Web.UI.Page 19 { 20 protected void Page_Load(object sender, EventArgs e) 21 { 22 23 } 24 25 protected void btnCalculate_Click(object sender, EventArgs e) 26 { 27 strWorkbookPath = @"http://denny:9001/sites/Wodeweb/Docs/ExcelServices/工资计算.xlsx"; 28 strSheetName = "Sheet1"; 29 strCultureName = "zh-cn"; 30 Status status = default(Status); 31 32 ExcelService es = ExcelService; 33 es.Credentials = CredentialCache.DefaultCredentials; 34 35 strSessionId = es.OpenWorkbook(strWorkbookPath, strCultureName, strCultureName, out status); 36 37 es.SetCellA1(strSessionId, strSheetName, "C2", this.txtC2.Text); 38 es.SetCellA1(strSessionId, strSheetName, "C3", this.txtC3.Text); 39 es.SetCellA1(strSessionId, strSheetName, "C4", this.txtC4.Text); 40 41 strResult = ()es.GetCellA1(strSessionId, strSheetName, "C6", true, out status); 42 43 (.IsNullOrEmpty(strResult) false) 44 { 45 this.lblC6.Text = strResult; 46 } 47 } 48 } 49} 8、至此 项目创建完毕 保存并运行该项目 在各个文本框中输入 些数字 然后单击“计算”按钮 9、这时 “实发”Label框后就已经出现了计算结果 至此 实现Excel Service就成功了 恭喜恭喜! 当然 这只是 个非常简单 例子 朋友们在实现这个Excel Service后 就可以根据自己 需要 尝试更为复杂 Excel Service了
相关文章
读者评论
发表评论
|
|