x

传送门,我们走...

DocX的Github传送门

介绍一

介绍二

写入特殊符号

开始...

自己做一个工具,要导出Word的,当时刚开始想使用Xceed.Words.NET.dll第三方插件进行开发。

但是网络上真的找不到太多相关资料来进行参考的好不好(不知道当初为毛要选择这个,听说很强大?)

然后搜到了中文资料比较多的一个第三方的插件:DocX.dll,听说也挺好用的。好吧就用它了,

并且找到了Github地址(本文中第一个门),下载一个Demo下来(感觉根据Demo调试生成下,一般操作完全Ok了),

生成Word,修改一下,感觉还不错。接着问题来了...Word中要插入特殊符号,

生成Word + 特殊符号...

/// <summary>
/// 生成Word
/// </summary>
public byte[] GetWordByte()
{
byte[] bytes = null;
try
{
List<string> list = new List<string>()
{
"我想要","生成","的数据。"
};
if (list.Count > )
{
string rootFolderPath = System.Configuration.ConfigurationManager.AppSettings["UploadFileAddress"]; ;//跟文件夹路径
int intUserID = XY.Global.XYRequestCache.RequestState.UserID;
string folderPath = "C:\\TestPath\\Word\\";
string fileName = "\\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "测试.docx";
string filePath = folderPath + fileName;
XYFileSystem FileSystem = new XYFileSystem();
if (File.Exists(folderPath))
{
System.IO.Directory.CreateDirectory(folderPath);
}
// Create a new document.
using (DocX document = DocX.Create(filePath))
{
// Add a title
//document.InsertParagraph("Adding Custom Properties to a document").FontSize(15d).SpacingAfter(50d).Alignment = Alignment.center;
foreach (var item in list)
{
double fontSize = 14d;
Paragraph retPar = document.InsertParagraph().Font("宋体").FontSize(fontSize);
retPar.Append(item).Font("宋体").FontSize(fontSize).AppendLine();
//特殊符号 //空心圆形
retPar.Append(string.Concat("\u25CB", "空心圆形A")).Font("宋体").FontSize(fontSize);
retPar.Append(string.Concat("\u25CB", "空心圆形B")).Font("宋体").FontSize(fontSize); //空心方形
retPar.Append(string.Concat("\u25A1", "空心方形A")).Font("宋体").FontSize(fontSize);
                    //下面示例中的特殊符号
                    if ("男" == "男")//纯属YuLe...
                    {
                      retPar.Append("\u0052男\u00A3女").Font("Wingdings 2").FontSize(fontSize);//这里设置字体类型
                    }
                    else
                    {
                      retPar.Append("\u0052女\u00A3男").Font("Wingdings 2").FontSize(fontSize);//这里设置字体类型
                    } } document.AddFooters(); //要添加的页脚,标识页数
//偶数[2,4,6,8...]页脚的样式...
// Add the page number in the even Footers.
//document.Footers.Even.InsertParagraph("").Font("Times New Roman").FontSize(9).AppendPageNumber(PageNumberFormat.normal);
var evenFooter = document.Footers.Even.InsertParagraph();
evenFooter.Font("Times New Roman").FontSize();
evenFooter.Alignment = Alignment.center;
document.Footers.Even.InsertParagraph(evenFooter).AppendPageNumber(PageNumberFormat.normal); //奇数[1,3,5,7...]页脚的样式...
// Add the page number in the odd Footers.
//document.Footers.Odd.InsertParagraph("").Font("Times New Roman").FontSize(9).AppendPageNumber(PageNumberFormat.normal);
var oddFooter = document.Footers.Even.InsertParagraph();
oddFooter.Font("Times New Roman").FontSize();
oddFooter.Alignment = Alignment.center;
document.Footers.Odd.InsertParagraph(oddFooter).AppendPageNumber(PageNumberFormat.normal); // Save this document to disk.
document.Save();
} #region 将文件转换为byte[]
//if (!File.Exists(filePath)) return null;
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
try
{
byte[] buffur = new byte[fs.Length];
fs.Read(buffur, , (int)fs.Length); bytes = buffur;
}
catch (Exception)
{
return null;
}
finally
{
if (fs != null)
{
fs.Close();
}
}
}
#endregion //清理痕迹,打扫磁盘战场...
File.Delete(filePath);
} return bytes;
}
catch (Exception)
{
//DO sth ...
}
return bytes;
}

特殊符号

这个绝对是,找了好长时间才找到!!!

直接复制原文了...

当我们要在word中输入选择框和打钩的选择框,我们可以这样:插入->符号->字体选择“Wingdings 2”。里面就有我们需要的选择框。

这里我们看到我们需要的打钩选择框的,字体是Wingdings 2,然后16进制的字符代码是0052,这样我们就可以利用这个来实现我们需要的字符

用之前同样的模板但是我们希望在性别这一栏采用选中框的方式展现效果,类似这样的//请看上面的代码...

写在最后...

一切都搞完了,回头看了下DocX的GitHub主页...

发现原来是一回事,但是免费的中文资料就还行,付费的真的不太好找...

"

DocX is the free, open source version of Xceed Words for .NET. Originally written by Cathal Coffey, and maintained by Przemyslaw Klys, it is now maintained by Xceed.

Currently, the only difference between DocX and Xceed Words for .NET, is that Xceed Words for .NET can convert a Word document to PDF, and has professional technical support included in the subscription.

"

Edition DocX Xceed Words for .NET
Price Free $499.95
License Ms-PL Proprietary
我只是 添加错了我...
并且不 知道怎么删这个表格..

x

DocX Xceed.Words.NET操作Word,插入特殊符号的更多相关文章

  1. c#调用Aspose.Word组件操作word 插入文字/图片/表格 书签替换套打

    由于NPOI暂时没找到书签内容替换功能,所以换用Apose.Word组件. using System; using System.Collections.Generic; using System.C ...

  2. C# 操作Word文本框——插入表格/读取表格/删除表格

    在文本框中,我们可以操作很多元素,如文本.图片.表格等,在本篇文章中将着重介绍如何插入表格到文本框,插入的表格我们可以对表格进行格式化操作来丰富表格内容.此外,对于文本框中的表格内容,我们也可以根据需 ...

  3. C# 操作Word 中的OLE——插入、编辑、读取 OLE

    概述 OLE,Object Linking and Embedding,即对象连接与嵌入.我们在设计程序时,OLE可以用来创建复合文档,把文字.声音.图像.表格.应用程序等类型的信息组合在一起,在Wo ...

  4. C# 操作Word书签(二)——插入图片、表格到书签;读取、替换书签

    概要 书签的设置可以帮助我们快速的定位某段文字,使用起来很方便,也很节省时间.在前一篇文章“C# 如何添加/删除Word书签”中介绍了插入.删除书签的方法,本篇文章将对C# 操作Word书签的功能做进 ...

  5. C#/VB.NET 操作Word批注(二)——如何插入图片、读取、回复Word批注内容

    序 在前面的文章C# 如何插入.修改.删除Word批注一文中介绍了如何操作Word批注的一些方法,在本篇文章中继续介绍操作Word批注的方法.分以下三种情况来介绍: 1. 插入图片到Word批注 2. ...

  6. C# /VB.NET操作Word批注(一)—— 插入、修改、删除Word批注

    批注内容可以是对某段文字或内容的注释,也可以是对文段中心思想的概括提要,或者是对文章内容的评判.疑问,以及在阅读时给自己或他人起到提示作用.本篇文章中将介绍如何在C#中操作Word批注,主要包含以下要 ...

  7. DocX操作word生成报表

    1.DocX简介 1.1 简介 DocX是一个在不需要安装word的情况下对word进行操作的开源轻量级.net组件,是由爱尔兰的一个叫Cathal Coffey的博士生开发出来的.DocX使得操作w ...

  8. C#操作word模板插入文字、图片及表格详细步骤

    c#操作word模板插入文字.图片及表格 1.建立word模板文件 person.dot用书签 标示相关字段的填充位置 2.建立web应用程序 加入Microsoft.Office.Interop.W ...

  9. C#操作Word文档(加密、解密、对应书签插入分页符)

    原文:C#操作Word文档(加密.解密.对应书签插入分页符) 最近做一个项目,客户要求对已经生成好的RTF文件中的内容进行分页显示,由于之前对这方面没有什么了解,后来在网上也找了相关的资料,并结合自己 ...

随机推荐

  1. MySQL入门(参考官网)

    目录 一.登陆和退出 1. 远程主机 2. 登陆本机 3. 退出mysql 二.输入查询 三.创建和使用数据库 3.1 创建和选择数据库 3.2 创建表 3.3 将数据加载到表中 3.4 操作表格 3 ...

  2. Android获取虚拟软键盘高度

    public static int getDpi(Context context) { int dpi = 0; WindowManager windowManager = (WindowManage ...

  3. Centos6.X搭建Squid为YUM做代理

    1.在能联网的机器上安装 Squid yum install squid 2.配置squid vi /etc/squid/squid.conf 编辑内容如下: http_port cache_mem ...

  4. Linux 首先基本包安装(vim啊什么的),源,源优化,项目架构介绍, (LNMuWsgi)Django项目相关软件mysql,redies,python(相关模块)安装配置测试

    内容 补充: 查看已启动服务的端口 netstat -tulnp |grep (方式1) ss -tulnp|grep (方式2) 前期铺垫: . Linux要能上网 . 掌握Linux软件包安装方法 ...

  5. centos7中nfs文件系统的使用

    需求: file01:1.1.1.1(内网ip 172.20.103.212),file02:2.2.2.2(内网ip 172.20.103.211) 这两台机器的 /dev/mapper/myvg- ...

  6. php base64图片保存

    function base64_image_content($base64_image_content,$path){ //匹配出图片的格式 if (preg_match('/^(data:\s*im ...

  7. Google Android SDK开发范例大全笔记 一

    方法讲解 1 获取手机分辨率方法 DisplayMetrics private void getDiaplayMetrics() { DisplayMetrics dm = new DisplayMe ...

  8. element-ui修改全局样式且只作用于当前页面

    1)修改组件的样式,但是只作用于当前页面,其他页面不受影响,做法有两种: 法一:使用关键字“/deep/” 1)在当前页面添加样式: <style lang="scss" s ...

  9. 饮冰三年-人工智能-Python-18Python面向对象

    1 类与实例对方法和属性的修改 class Chinese: # 这是一个Chinese的类 #定义一个类属性,又称为静态数据或者静态变量,相当于C#中的static country="Ch ...

  10. Java Spring Boot VS .NetCore (九) Spring Security vs .NetCore Security

    Java Spring Boot VS .NetCore (一)来一个简单的 Hello World Java Spring Boot VS .NetCore (二)实现一个过滤器Filter Jav ...