using System;
using Microsoft.Office.Interop.Word;
using Word = Microsoft.Office.Interop.Word;
namespace WordList
{
class WordList
{
static void Main(string[] args)
{
string message = "";
try
{
Object Nothing = System.Reflection.Missing.Value;
object filename = "d://WordList.doc";
Word.Application app = new Word.ApplicationClass();
Word.Document doc = app.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing); doc.Paragraphs[].Range.Text = "段落一"; doc.Paragraphs.Add(ref Nothing);
doc.Paragraphs[].Range.Text = "段落二"; doc.Paragraphs.Add(ref Nothing);
doc.Paragraphs[].Range.Text = "段落三"; doc.Paragraphs.Add(ref Nothing);
doc.Paragraphs[].Range.Text = "段落四"; object i = ;
object t = true;
Word.ListTemplate listTemp = app.ListGalleries[Word.WdListGalleryType.wdBulletGallery].ListTemplates.get_Item(ref i);
app.ActiveDocument.Paragraphs[].Range.ListFormat.ApplyListTemplate(listTemp, ref t, ref Nothing, ref Nothing);
app.ActiveDocument.Paragraphs[].Range.ListFormat.ApplyListTemplate(listTemp, ref t, ref Nothing, ref Nothing);
app.ActiveDocument.Paragraphs[].Range.ListFormat.ApplyListTemplate(listTemp, ref t, ref Nothing, ref Nothing);
app.ActiveDocument.Paragraphs[].Range.ListFormat.ApplyListTemplate(listTemp, ref t, ref Nothing, ref Nothing); doc.SaveAs(ref filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
doc.Close(ref Nothing, ref Nothing, ref Nothing);
app.Quit(ref Nothing, ref Nothing, ref Nothing);
message = "文档生成成功";
}
catch (Exception e)
{
message = "文件导出异常!" + e;
} Console.WriteLine(message);
}
}
}

不懂c#所以先记下来

参考:

http://www.cnblogs.com/yuxia/archive/2013/07/31/3227503.html

http://blog.sina.com.cn/s/blog_533506c10100ax8w.html

感谢:

http://q.cnblogs.com/q/57022/

C#生成带项目编号的Word段落的更多相关文章

  1. java生成带html样式的word文件

    参考:http://blog.csdn.net/xiexl/article/details/6652230 最近在项目中需要将通过富文本编辑器处理过的文字转换为Word,查了很久,大家通常的解决办法是 ...

  2. 利用freemarker生成带fusioncharts图片的word简报

    /**  * 利用freemarker生成带fusioncharts图片的word简报  *         烟台海颐软件技术论坛  *         作者  牟云飞 新建 *         毕业 ...

  3. 如何修改word的项目编号

    在操作word文档时,有时会遇到word文档中的项目编号不是自己需要的,并造成word项目编号的混乱,如何word中的两级项目编号不统一,为解决会word的项目编号混乱问题,小编将教大家如何修改wor ...

  4. 【手摸手,带你搭建前后端分离商城系统】02 VUE-CLI 脚手架生成基本项目,axios配置请求、解决跨域问题

    [手摸手,带你搭建前后端分离商城系统]02 VUE-CLI 脚手架生成基本项目,axios配置请求.解决跨域问题. 回顾一下上一节我们学习到的内容.已经将一个 usm_admin 后台用户 表的基本增 ...

  5. js生成带参的二维码

    最近项目中有需求生成带参的二维码,考虑过用JAVA后台生成返回前端展示,后面了解到用jquery的qrcode.js插件可以很好现实 引入js: require.config({ baseUrl : ...

  6. T4 模板自动生成带注释的实体类文件

    T4 模板自动生成带注释的实体类文件 - 只需要一个 SqlSugar.dll 生成实体就是这么简单,只要建一个T4文件和 文件夹里面放一个DLL. 使用T4模板教程 步骤1 创建T4模板 如果你没有 ...

  7. vue-cli生成的项目配置开发和生产环境不同的接口

    vue-cli生成的项目,vue项目配置了不同开发环境的接口地址,axios.defaults.baseURL如何引用这个地址,这是在我发布项目的时候考虑的,于是想到了 方法一: config下配置文 ...

  8. 读取数据库信息并生成表设计文档Word版本

    1.参考C#代码 using Help.DBAccessLayer.Business; using Help.DBAccessLayer.Model.SqlGenerator; using Newto ...

  9. 使用CMake生成sln项目和VS工程遇到的问题

    用vs运行cmake后的工程 参考:http://zhidao.baidu.com/link?url=AZRxI0jGDzo6Pikk68qylee0g7leXbpbZGiVuyiijWbd8scUK ...

随机推荐

  1. DB2 错误编码 查询(二)(转)

    DB2 SQLSTATE 讯息 类代码 42 语法错误或访问规则违例表 32. 类代码 42:语法错误或访问规则违例 SQLSTATE 值   含义 42501 授权标识不具有对标识对象执行指定操作的 ...

  2. 数据库存储过程 — Sql Server

    Mysql.Oracle等主流关系型数据库基本都支持存储过程,这里使用Sql Server为例进行说明. 存储过程的概念: Sql Server存储过程 SQL Server 中的存储过程是由一个或多 ...

  3. Adobe/Flash Media Server 5.0 linux 64位系统下的安装

    一.下载 Adobe/Flash MS5.0下载地址: http://fs1.d-h.st/download/00036/VOt/adobemediaserver_5_ls1_linux64.tar. ...

  4. openwrt interface

    orige : http://www.cnblogs.com/preorder69/p/3959187.html 这篇算是对openwrt网络接口的一个翻译吧,源地址:http://wiki.open ...

  5. Sass插值、注释、数剧类型、字符串、值类型

    插值#{}使用 CSS 预处理器语言的一个主要原因是想使用 Sass 获得一个更好的结构体系.比如说你想写更干净的.高效的和面向对象的 CSS.Sass 中的插值(Interpolation)就是重要 ...

  6. DOM中的NodeList与HTMLCollection

    最近在看<Javascript高级程序设计>的时候,看到了这样一句话:“理解NodeList和HTMLCollection,是从整体上透彻理解DOM的关键所在.”,所以觉得应该写一篇关于N ...

  7. Swift中的便利构造器和构造器链

    import UIKit // 1.一个类中至少有一个指定构造器, 其必须负责初始化类中所有的实例存储属性 // 2.便利构造器属于次要的, 辅助性的构造器 // 3.类中可以不定义便利构造器, 便利 ...

  8. C#学习笔记之结构体

    1.概述 结构是一种与类相似的数据类型,不过它较类更为轻量,一般适用于表示类似Point.Rectangle.Color的对象.基本上结构能办到的类全都能办到,但在某些情况下使用结构更为合适,后面会有 ...

  9. C/C++中字符串存储位置

    代码: #include <iostream> #include <cstdio> using namespace std; void fun(char **p){ //cha ...

  10. Sql Server 连接池及其用法

    其实我们一直在使用SqlServer的连接池.在连接字符串中,Pooling为是否启用连接池,默认值为true,表示启用. 与连接池相关的两个重要参数是 Min Pool Size和 Max Pool ...