OpenXML 操作例子
来源:互联网 发布:js判断是否为function 编辑:程序博客网 时间:2024/04/30 22:27
Creating a new document
using (WordProcessingMLDocument myDoc =
WordProcessingMLDocument.Open(@"C:/myDoc.docx"))
{
Paragraph paragraph = myDoc.Body.Paragraphs.New();
paragraph.AddText("Hello World!");
myDoc.Save();
}
Insert a custom XML file
using (WordProcessingMLDocument myDoc =
WordProcessingMLDocument.Open(@"C:/myDoc.docx"))
{
myDoc.CustomXml.Add(@"C:/customXML.xml");
}
Import a paragraph from a document
using (WordProcessingMLDocument sourceDoc =
WordProcessingMLDocument.Open(@"C:/source.docx"))
using (WordProcessingMLDocument targetDoc =
WordProcessingMLDocument.Open(@"C:/target.docx"))
{
Paragraph paragraph = sourceDoc.Body.Paragraphs 1;
targetDoc.Body.Insert(paragraph);
targetDoc.Save();
}
Move a paragraph inside the document to a specific location (after the third table in this sample)
using (WordProcessingMLDocument myDoc =
WordProcessingMLDocument.Open(@"C:/myDoc.docx"))
{
Paragraph paragraph = myDoc.Body.Paragraphs1;
Table table = myDoc.Body.Tables3;
myDoc.Body.Paragraphs.InsertAfter(
paragraph, table);
myDoc.Save();
}
using (WordProcessingMLDocument myDoc =
WordProcessingMLDocument.Open(@"C:/myDoc.docx"))
{
Paragraph paragraph = myDoc.Body.Paragraphs.New();
paragraph.AddText("Hello World!");
myDoc.Save();
}
Insert a custom XML file
using (WordProcessingMLDocument myDoc =
WordProcessingMLDocument.Open(@"C:/myDoc.docx"))
{
myDoc.CustomXml.Add(@"C:/customXML.xml");
}
Import a paragraph from a document
using (WordProcessingMLDocument sourceDoc =
WordProcessingMLDocument.Open(@"C:/source.docx"))
using (WordProcessingMLDocument targetDoc =
WordProcessingMLDocument.Open(@"C:/target.docx"))
{
Paragraph paragraph = sourceDoc.Body.Paragraphs 1;
targetDoc.Body.Insert(paragraph);
targetDoc.Save();
}
Move a paragraph inside the document to a specific location (after the third table in this sample)
using (WordProcessingMLDocument myDoc =
WordProcessingMLDocument.Open(@"C:/myDoc.docx"))
{
Paragraph paragraph = myDoc.Body.Paragraphs1;
Table table = myDoc.Body.Tables3;
myDoc.Body.Paragraphs.InsertAfter(
paragraph, table);
myDoc.Save();
}
- OpenXML 操作例子
- OpenXML例子
- OpenXML读写EXCEL的例子
- OPENXML
- Openxml
- OPENXML
- OPENXML
- OPENXML
- openxml操作word的基本应用
- 关于Openxml和c#操作office
- OpenXML操作excel创建和删除工作表
- 使用OPENXML(Using OpenXML)
- OpenXml操作Word的一些操作总结.无word组件生成word.
- OpenXml操作Word的一些操作总结.无word组件生成word.
- OpenXml操作Word的一些操作总结.无word组件生成word.
- OpenXML 方法
- openxml文章
- 初识OpenXml
- 红十字会:本次募捐100%用于灾区 不再提留10%
- ASP.Net页面实现ICallbackEventHandler接口,不能工作的问题。
- 页面变黑白方法
- VirtualAlloc 分配与访问测试代码(double类型)
- Mavenir Systems 期待新生活
- OpenXML 操作例子
- Oracle10g 给scott用户解锁
- 进程和线程有什么区别
- PHP的未来 - Zeev Suraski访谈录
- SAP R/3
- C/C++笔试题 (1)
- 在视图内的某点显示系统时间
- 2008-05-17 ITIL本地化实施沙龙活动记录
- C/C++笔试题 (2)