c# aspose操作word文档
背景
这个是一个操作word文档的插件
1.1插入图片
using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Rendering;
Document doc = new Document(TempValue);//TempValue doc模板的路径
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = new Shape(doc,ShapeType.Image);
shape.ImageData.SetImage(Server.MapPath("Images/test.jpg"));
shape.Width = 70;//设置宽和高
shape.Height = 70;
shape.WrapType = WrapType.None;
shape.BehindText = true;
//shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
//shape.HorizontalAlignment = HorizontalAlignment.Center;
//shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
//shape.VerticalAlignment = VerticalAlignment.Center;
//shape.HorizontalAlignment = HorizontalAlignment.Center;
builder.MoveToBookmark("PO_MyImage");
builder.InsertNode(shape);
doc.Save("newword.doc",SaveFormat.Doc);
1.2删除指定段落
// 根据表格找到所在段落
var paragraph = (Paragraph) table.GetAncestor(NodeType.Paragraph);
// 清除段落前的分页符
if (paragraph.ParagraphFormat.PageBreakBefore)
paragraph.ParagraphFormat.PageBreakBefore = false;
// 清除段落中的分页符
foreach (Run run in paragraph.Runs)
{
if (run.Text.Contains(ControlChar.PageBreak))
run.Text = run.Text.Replace(ControlChar.PageBreak, string.Empty);
}
1.3合并文档
Document doc = new Document();
// We should call this method to clear this document of any existing content.
doc.RemoveAllChildren();
int recordCount = 5;
for (int i = 1; i <= recordCount; i++)
{
// Open the document to join.
Document srcDoc = new Document(@"C:\DetailsList.doc");
// Append the source document at the end of the destination document.
doc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);
// In automation you were required to insert a new section break at this point, however in Aspose.Words we
// don't need to do anything here as the appended document is imported as separate sectons already.
// If this is the second document or above being appended then unlink all headers footers in this section
// from the headers and footers of the previous section.
if (i > 1)
doc.Sections[i].HeadersFooters.LinkToPrevious(false);
}
1.4合并的时候在同一页显示
Document dstDoc = new Document(gDataDir + "TestFile.Destination.doc");
Document srcDoc = new Document(gDataDir + "TestFile.Source.doc");
// Make the document appear straight after the destination documents content.
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
// Append the source document using the original styles found in the source document.
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
dstDoc.Save(gDataDir + "TestFile.JoinContinuous Out.doc");
1.5合并的时候再另外一页开始
Document dstDoc = new Document(gDataDir + "TestFile.Destination.doc");
Document srcDoc = new Document(gDataDir + "TestFile.Source.doc");
// Set the appended document to start on a new page.
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;
// Append the source document using the original styles found in the source document.
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
dstDoc.Save(gDataDir + "TestFile.JoinNewPage Out.doc");
1.6其他的一些信息
https://blog.csdn.net/ibigpig/article/details/8432245
1.7 Spire.Doc与Aspose.Words功能对比
http://www.cnblogs.com/dare/archive/2018/07/03/9259417.html
c# aspose操作word文档的更多相关文章
- iText操作word文档总结
操作word文档的工具有很多,除了iText之外还有POI,但是POI擅长的功能是操作excel,虽然也可以操作word,但是能力有限,而且还有很多的bug,技术并不成熟,下面就重点介绍一种操作wor ...
- C#操作Word文档(加密、解密、对应书签插入分页符)
原文:C#操作Word文档(加密.解密.对应书签插入分页符) 最近做一个项目,客户要求对已经生成好的RTF文件中的内容进行分页显示,由于之前对这方面没有什么了解,后来在网上也找了相关的资料,并结合自己 ...
- 利用Python操作Word文档【图片】
利用Python操作Word文档
- Java文件操作系列[3]——使用jacob操作word文档
Java对word文档的操作需要通过第三方组件实现,例如jacob.iText.POI和java2word等.jacob组件的功能最强大,可以操作word,Excel等格式的文件.该组件调用的的是操作 ...
- QTP操作word文档
QTP可以对word文档进行操作,这里最主要展示的是向word文档写入内容,并保存的功能. Option explicit Dim wordApp Set wordApp = createobject ...
- c#中操作word文档-四、对象模型
转自:http://blog.csdn.net/ruby97/article/details/7406806 Word对象模型 (.Net Perspective) 本文主要针对在Visual St ...
- python 操作word文档
因为工作需要操作一些word文档,记录一下学习思路 #-*- encoding: utf8 -*- import win32com from win32com.client import Dispat ...
- 2.QT中操作word文档
Qt/Windows桌面版提供了ActiveQt框架,用以为Qt和ActiveX提供完美结合.ActiveQt由两个模块组成: A QAxContainer模块允许我们使用COM对象并且可以 ...
- C# 操作Word 文档——添加Word页眉、页脚和页码
在Word文档中,我们可以通过添加页眉.页脚的方式来丰富文档内容.添加页眉.页脚时,可以添加时间.日期.文档标题,文档引用信息.页码.内容解释.图片/LOGO等多种图文信息.同时也可根据需要调整文字或 ...
- Java操作word文档使用JACOB和POI操作word,Excel,PPT需要的jar包
可参考文档: http://wibiline.iteye.com/blog/1725492 下载jar包 http://download.csdn.net/download/javashixiaofe ...
随机推荐
- php的php-fpm
FastCgi与PHP-fpm到底是个什么样的关系 昨晚有一位某知名在线教育的大佬问了我一个问题,你知道php-fpm和cgi之间的关系吗?作为了一个5年的phper了,这个还不是很简单的问题,然后我 ...
- [win10] 开始-设置 / 右键-显示设置 / 右键个性化 等都不好使了。。 ms-settings:display
现象: 各种win10自带的都打不开了. 发现: 最近总是断网,重启下就好了,然后点击网络,就一直出不来.后来发现所有win10的窗口都出不来了.控制面板等等. 解决:好消息是最后解决了.坏消息是没有 ...
- springboot打jar包
参考,欢迎点击原文:https://www.jianshu.com/p/84883627db67(简书) https://www.cnblogs.com/dk1024/p/10802007.html( ...
- 【Mahjong hdu 枚举】搜索枚举
#####枚举 import java.io.*; import java.util.*; public class Main { static HashSet<String> set1; ...
- 5G+实时云渲染:交互实时云看车革新购车体验
随着科技的发展,用户的购车方式已然发生了改变. 传统的购车过程中,用户需要亲自去4S店看车.选车.预约试驾,最后完成交易. 互联网的发展和突如其来的疫情,让看车.选车.预约试驾这三个过程,逐步被搬到线 ...
- InfluxDB、Grafana、node_exporter、Prometheus搭建压测平台
InfluxDB.Grafana.node_exporter.Prometheus搭建压测平台 我们的压测平台的架构图如下: 配置docker环境 1)yum 包更新到最新 sudo yum upda ...
- 新零售SaaS架构:线上商城系统架构设计
零售商家为什么要建设线上商城? 传统的实体门店服务范围有限,只能吸引周边500米以内的消费者.因此,如何拓展服务范围,吸引更多的消费者到店,成为了店家迫切需要解决的问题. 缺乏忠实顾客,客户基础不稳, ...
- 记录--vue3的宏到底是什么东西?
这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助 前言 从vue3开始vue引入了宏,比如defineProps.defineEmits等.我们每天写vue代码时都会使用到这些宏,但是你有 ...
- JavaScript知识总结 基础篇
这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助 1. new操作符的实现原理 new操作符的执行过程: (1)首先创建了一个新的空对象 (2)设置原型,将对象的原型设置为函数的 prot ...
- 使用Go语言开发一个短链接服务:四、生成code算法
章节 使用Go语言开发一个短链接服务:一.基本原理 使用Go语言开发一个短链接服务:二.架构设计 使用Go语言开发一个短链接服务:三.项目目录结构设计 使用Go语言开发一个短链接服务:四.生成 ...