Aspose.Words二 基础
1、目录样式
doc.Styles[Aspose.Words.StyleIdentifier.Toc1].Font.Size = 14;
doc.Styles[Aspose.Words.StyleIdentifier.Toc1].Font.Bold = false;
doc.Styles[Aspose.Words.StyleIdentifier.Toc1].ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Distributed;
doc.Styles[Aspose.Words.StyleIdentifier.Toc1].ParagraphFormat.LeftIndent = 0;
doc.Styles[Aspose.Words.StyleIdentifier.Toc1].ParagraphFormat.SpaceBefore = 0;
doc.Styles[Aspose.Words.StyleIdentifier.Toc1].ParagraphFormat.SpaceAfter = 0;
2、更新目录
doc.UpdateFields();
3、首行缩进、间距
var newPara = builder.InsertParagraph();
//首行缩进
newPara.ParagraphFormat.FirstLineIndent = 24;
//间距
newPara.ParagraphFormat.SpaceAfter = 0;
newPara.ParagraphFormat.SpaceBefore = 0;
var run = (Aspose.Words.Run)targetRun.Clone(true);
run.Text = contentArray[i];
newPara.Runs.Add(run);
4、水平居中
newPara.ParagraphFormat.Alignment = ParagraphAlignment.Center;
5、表水平居中
var table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
table.Alignment = TableAlignment.Center;
6、表格样式
//设置边框颜色
builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Red;
//设置边框样式
builder.CellFormat.Borders.Top.LineStyle = LineStyle.Double;
7、合并行和列
string templateFile = Server.MapPath("table_templ.doc");
string saveDocFile = Server.MapPath("table.doc");
Aspose.Words.Document doc = new Aspose.Words.Document(templateFile);
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
#region 添加第一行
//第一行第一列
builder.InsertCell();
//垂直居中
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
//水平居中
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
//合并行
builder.CellFormat.VerticalMerge = CellMerge.First;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.Write("合并行");
//第一行第二列
builder.InsertCell();
//合并列
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.Write("合并列");
//第一行第三列
builder.InsertCell();
//合并列
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
//设置边框颜色
builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Red;
//设置边框样式
builder.CellFormat.Borders.Top.LineStyle = LineStyle.Double;
//builder.CellFormat.Borders.Top.LineStyle = LineStyle.Single;
//第一行第四列
builder.InsertCell();
//合并列
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.Write("第一行第四列");
builder.EndRow();
#endregion
#region 添加第二行
//第二行第一列
builder.InsertCell();
builder.CellFormat.VerticalMerge = CellMerge.Previous;
builder.CellFormat.HorizontalMerge = CellMerge.None;
//第二行第二列
builder.InsertCell();
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.Write("第二行第二列");
//第二行第二列
builder.InsertCell();
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.Write("第二行第三列");
//第二行第二列
builder.InsertCell();
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.Write("第二行第四列");
builder.EndRow();
#endregion
//表格水平居中
var table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
table.Alignment = TableAlignment.Center;
doc.Save(saveDocFile);
Aspose.Words二 基础的更多相关文章
- 「kuangbin带你飞」专题十二 基础DP
layout: post title: 「kuangbin带你飞」专题十二 基础DP author: "luowentaoaa" catalog: true tags: mathj ...
- MVC3+EF4.1学习系列(二)-------基础的增删改查和持久对象的生命周期变化
上篇文章中 我们已经创建了EF4.1基于code first的例子 有了数据库 并初始化了一些数据 今天这里写基础的增删改查和持久对象的生命周期变化 学习下原文先把运行好的原图贴来上~~ 一.创建 ...
- https学习笔记二----基础密码学知识和python pycrypto库的介绍使用
在更详细的学习HTTPS之前,我也觉得很有必要学习下HTTPS经常用到的加密编码技术的背景知识.密码学是对报文进行编解码的机制和技巧.可以用来加密数据,比如数据加密常用的AES/ECB/PKCS5Pa ...
- RabbitMQ系列(二)--基础组件
声明:对于RabbitMQ的学习基于某课网相关视频和<RabbitMQ实战指南>一书,后续关于RabbitMQ的博客都是基于二者 一.什么是RabbitMQ RabbitMQ是开源代理和队 ...
- .NET 云原生架构师训练营(模块二 基础巩固 MongoDB 介绍和基础)--学习笔记
2.5.1 MongoDB -- 介绍 mysql vs mongo 快速开始 mysql vs mongo 对比 mysql mongo 数据存储 table 二维表结构,需要预先定义结构 json ...
- Git系列教程二 基础介绍
一.存储方式 如果让我们设计一个版本控制系统,最简单的方式就是每做一次更改就生成一个新的文件. 这样的方式太占用空间,所以传统的版本控制系统都是保存一个文件的某个版本的全部内容以及其他版本相对于这个版 ...
- python入门到精通[二]:基础学习(1)
摘要:Python基础学习: 注释.字符串操作.用户交互.流程控制.导入模块.文件操作.目录操作. 上一节讲了分别在windows下和linux下的环境配置,这节以linux为例学习基本语法.代码部分 ...
- GIT之二 基础篇(1)
GIT基础 取得项目的 Git 仓库 有两种取得 Git 项目仓库的方法.第一种是在现存的目录下,通过导入所有文件来创建新的 Git 仓库.第二种是从已有的 Git 仓库克隆出一个新的镜像仓库来. 在 ...
- MongoDB之二基础入门(安装启动)
mongodb中有三元素:数据库,集合,文档,其中“集合” 就是对应关系数据库中的“表”,“文档”对应“行”. 一. 下载 上MongoDB官网 ,我们发现有32bit和64bit,这个就要看你系统了 ...
随机推荐
- E_FAIL (0x80004005) MachineWrap
下载VirtualBox-4.3.12-93733-Win.exe,下载地址:http://download.virtualbox.org/virtualbox/4.3.12/
- zatree的安装
zatree的安装有2种 一种是支持2.x的用以下方法安装 zabbix安装zatree 实现图形树状化 官网:https://github.com/spide4k/zatree [root@SERV ...
- nginx的websock问题解决
生产环境中有一个项目需要使用到websock,但是项目上线后发现websock连接后马上断开,但是在测试环境没有问题,后来就想到配置文件和nginx版本问题 核对后发现,nginx和配置文件都是相同的 ...
- [ SHELL编程 ] 编程常用的ORACLE相关命令
本文主要描述shell编程中常用的Oracle相关命令. 1.sqlplus -L/-S参数 sqlplus -L user/password #-L参数表示用户只尝试登录一次, 而不是在出错时再次提 ...
- Eclipse绿豆沙护眼
Window-->Preferences-->Editors——>Text Editors —— Background color 背景颜色向你推荐:色调:85.饱和度:123.亮度 ...
- centos 下安装redis
一.安装redis 第一步:下载redis安装包 redis下载地址 wget http://download.redis.io/releases/redis-5.0.3.tar.gz 第二步:解压压 ...
- webui-popover 一个轻量级的jquery弹出层插件
该提示框插件可以和Bootstrap完美结合,但是并不一定需要和Bootstrap一起使用.它支持IE7以上的浏览器. 首先要引入需要的css js 文件 <link rel="s ...
- 微信小程序--分享报错(thirdScriptError Cannot read property 'from' of undefined;at pages/index/index page onShareAppMessage function TypeError: Cannot read property 'from' of undefined)
分享功能: onShareAppMessage: function (res) { if (res.from === 'button') { // 来自页面内转发按钮 console.log(res. ...
- 02_数据库基础之(二)sql语句入门
1.基本增删改查操作 #一. 数据类型 常用的3中 # .字符串 例如:你的名字 我是中国人 在数据库中要使用 ‘’引起来 '苹果手机' # .整数类型 例如: 你的年龄 ,办公室的人数 个 ,直接使 ...
- DNS隧道 iodns
通过iodns这个工具也能搭建DNS隧道 iodns的优点: 对下行数据不进行编码,速度快 支持多平台 最大16个并发连接 强制密码设定 iodns创建的DNS隧道网段不能喝服务器,客户端同一网段,比 ...