博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OpenXML 操作例子
阅读量:4116 次
发布时间:2019-05-25

本文共 1045 字,大约阅读时间需要 3 分钟。

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 ;
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.Paragraphs ;
Table table = myDoc.Body.Tables ;
myDoc.Body.Paragraphs.InsertAfter(
paragraph, table);
myDoc.Save();
}

转载地址:http://mrkpi.baihongyu.com/

你可能感兴趣的文章
实例区别BeanFactory和FactoryBean
查看>>
Spring后置处理器BeanPostProcessor的应用
查看>>
Spring框架的ImportSelector到底可以干嘛
查看>>
Mysql中下划线问题
查看>>
微信小程序中使用npm过程中提示:npm WARN saveError ENOENT: no such file or directory
查看>>
Xcode 11 报错,提示libstdc++.6 缺失,解决方案
查看>>
idea的安装以及简单使用
查看>>
Windows mysql 安装
查看>>
python循环语句与C语言的区别
查看>>
Vue项目中使用img图片和background背景图的使用方法
查看>>
vue 项目中图片选择路径位置static 或 assets区别
查看>>
vue项目打包后无法运行报错空白页面
查看>>
Vue 解决部署到服务器后或者build之后Element UI图标不显示问题(404错误)
查看>>
element-ui全局自定义主题
查看>>
facebook库runtime.js
查看>>
vue2.* 中 使用socket.io
查看>>
openlayers安装引用
查看>>
js报错显示subString/subStr is not a function
查看>>
高德地图js API实现鼠标悬浮于点标记时弹出信息窗体显示详情,点击点标记放大地图操作
查看>>
初始化VUE项目报错
查看>>