简体   繁体   English

C#以编程方式填写InfoPath表单?

[英]C# to fill out InfoPath Form programmatically?

Is it possible to fill out an infopath form and submit it via a C# console application? 是否可以填写信息表格并通过C#控制台应用程序提交?

If yes, then how? 如果是,那怎么样?

Yes, you can create a XML file within your C# application and push it to your Sharepoint Form Library. 是的,您可以在C#应用程序中创建XML文件并将其推送到Sharepoint表单库。 Sharepoint won't realize any difference. Sharepoint不会发现任何差异。

Just ensure two things: 确保两件事:

  • Your XML must validate against the Infopath schema . 您的XML必须根据Infopath 架构进行验证。
  • Remember to add the XML processing instructions , so that Sharepoint and Infopath know how to handle the XML file. 请记住添加XML 处理指令 ,以便Sharepoint和Infopath知道如何处理XML文件。 (Simply 'steal' it from an Infopath generated XML.) (简单地从Infopath生成的XML中“窃取”它。)

MrFox is right, an Infopath Form is just an Xml document that conforms to certain rules, so as long as you create the text file with the correct Xml markups, then you've created an Infopath doc. MrFox是对的,Infopath表单只是一个符合某些规则的Xml文档,因此只要您使用正确的Xml标记创建文本文件,那么您就创建了一个Infopath文档。 There are, however, programmatical ways to manipulate a document using the Infopath space. 但是,有一些使用Infopath空间操作文档的编程方法。 In particular, you can create a new Infopath document from an Infopath template. 特别是,您可以从Infopath模板创建新的Infopath文档。 Lookup more information on XDocuments2.NewFromSolution() to see some examples. 查看有关XDocuments2.NewFromSolution()更多信息,以查看一些示例。

  • Identify field names and their XML representation 识别字段名称及其XML表示
  • Read InfoPath form item from InfoPath document Library 从InfoPath文档库中读取InfoPath表单项
  • Load attached InfoPath form's XML representation to XmlTextReader 将附加的InfoPath表单的XML表示加载到XmlTextReader
  • Read each node using XmlTextReader and extract user input based on our requirement 使用XmlTextReader读取每个节点,并根据我们的要求提取用户输入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM