利用Microsoft Office InfoPath结合C#编程

   我想这里利用WEB服务来与InfoPath交互数据是最方便的了,InfoPath只能从数据库(SQL Server、Access)中提取数据,而不能直接编辑数据。通过WEB服务,InfoPath提交XML数据,服务来进一步处理数据。InfoPath的页面也可以做的比较漂亮,与Web页面相当。

  不过在这里,InfoPath生成的模板中保存着原来的物理路径,把模板文件拷到别的机子上就无法打开填写表单,不知道这是什么问题?

  研究了一段时间InfoPath,使用起来还是很方便的。在设计模板的时候,其每种控件都可以添加验证条件以及自定交的规则,操作起来也很方便,即使不太懂编程也不要紧。

    从网上发现一组件InfoPath 2003 Toolkit for Visual Studio .NET可以和.net框架集成一起,并可以利用C#编辑后台代码,来扩展程序的功能。当安装成功后,在Microsoft Visual Studio .NET 2003中新建项目时会有一项新的新建项目类型。如下图:

请单击此链接: 开始下载.   InfoPath 2003 Toolkit for Visual Studio .NET

 

示例:C#后台代码

           

using System;

using System.Web;

using System.Web.UI;

using Microsoft.Office.Interop.InfoPath.SemiTrust;

 

// Office 集成属性,指明表单的 startup 类。不要修改。

[assembly: System.ComponentModel.DescriptionAttribute("InfoPathStartupClass, Version=1.0, Class=InfoPathProject1.InfoPathProject1")]

 

namespace InfoPathProject1

{

     // 属性中定义的命名空间前缀必须与表单定义文件(.xsf)中的同步。

     [InfoPathNamespace("xmlns:xdUtil=/"http://schemas.microsoft.com/office/infopath/2003/xslt/Util/"

     xmlns:xdXDocument=/"http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument/"

     xmlns:xd=/"http://schemas.microsoft.com/office/infopath/2003/"

     xmlns:my=/"http://schemas.microsoft.com/office/infopath/2003/myXSD/ 2006-03-15 T02:16:17/"

     xmlns:msxsl=/"urn:schemas-microsoft-com:xslt/" xmlns:xdMath=/"http://schemas.microsoft.com/office/infopath/2003/xslt/Math/"

     xmlns:xsf=/"http://schemas.microsoft.com/office/infopath/2003/solutionDefinition/"

     xmlns:xdDate=/"http://schemas.microsoft.com/office/infopath/2003/xslt/Date/"

     xmlns:xsi=/"http://www.w3.org/ 2001 /XMLSchema-instance/"")]

     public class InfoPathProject1

     {

          private XDocument  thisXDocument;

          private Application    thisApplication;

 

          public void _Startup(Application app, XDocument doc)

          {

               thisXDocument = doc;

               thisApplication = app;

 

               // 您可以在此添加其他初始化代码。

          }

          public void _Shutdown()

          {

              

          }        

     }

}

 

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值