如何在Word 2007模板中使用OpenXML? [英] how to use OpenXML with word 2007 template?
本文介绍了如何在Word 2007模板中使用OpenXML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Word 2007模板中使用OpenXML?
我要替换模板标记
并生成文档
在asp.net c#
对不起,我的英语很不好,我正在学习
Help
how to use OpenXML with word 2007 template?
I want to replace the template markers
and generate the document
in asp.net c #
sorry for my English is very bad I''m learning
Help
推荐答案
它必须是一个真实的模板吗?我问是因为这意味着某种邮件合并"类型的过程,该过程不能/不应该在服务器上完成.
如果可以使用常规的Word文档,请
打开XML [ ^ ]将生成一个用于创建文档的类,您可以在其中用实际数据替换模板"字段.
在生成的代码中,它将类似于以下内容:
Does it have to be a real template? I am asking because that implies some sort of "mail merge" type process, which can''t/shouldn''t be done on the server.
If you can use a regular Word document,
the Open XML [^] will generate a class for creating the doc in which you can replace the ''template'' fields with the real data.
In the generated code, it will look something like this:
Run run1 = new Run();
Text text1 = new Text();
text1.Text = "This is a fake template, and here is the DATA1";
run1.Append(text1);
paragraph1.Append(run1);
但您可以将其更改为:
but you''d change it to this:
Run run1 = new Run();
Text text1 = new Text();
text1.Text = "This is a fake template, and here is the "+DATA1;
run1.Append(text1);
paragraph1.Append(run1);
并在运行时替换所有变量.
And replace all your variables at runtime.
这篇关于如何在Word 2007模板中使用OpenXML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文