C#生成带项目编号的Word段落
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
感谢:
C#生成带项目编号的Word段落的更多相关文章
- java生成带html样式的word文件
参考:http://blog.csdn.net/xiexl/article/details/6652230 最近在项目中需要将通过富文本编辑器处理过的文字转换为Word,查了很久,大家通常的解决办法是 ...
- 利用freemarker生成带fusioncharts图片的word简报
/** * 利用freemarker生成带fusioncharts图片的word简报 * 烟台海颐软件技术论坛 * 作者 牟云飞 新建 * 毕业 ...
- 如何修改word的项目编号
在操作word文档时,有时会遇到word文档中的项目编号不是自己需要的,并造成word项目编号的混乱,如何word中的两级项目编号不统一,为解决会word的项目编号混乱问题,小编将教大家如何修改wor ...
- 【手摸手,带你搭建前后端分离商城系统】02 VUE-CLI 脚手架生成基本项目,axios配置请求、解决跨域问题
[手摸手,带你搭建前后端分离商城系统]02 VUE-CLI 脚手架生成基本项目,axios配置请求.解决跨域问题. 回顾一下上一节我们学习到的内容.已经将一个 usm_admin 后台用户 表的基本增 ...
- js生成带参的二维码
最近项目中有需求生成带参的二维码,考虑过用JAVA后台生成返回前端展示,后面了解到用jquery的qrcode.js插件可以很好现实 引入js: require.config({ baseUrl : ...
- T4 模板自动生成带注释的实体类文件
T4 模板自动生成带注释的实体类文件 - 只需要一个 SqlSugar.dll 生成实体就是这么简单,只要建一个T4文件和 文件夹里面放一个DLL. 使用T4模板教程 步骤1 创建T4模板 如果你没有 ...
- vue-cli生成的项目配置开发和生产环境不同的接口
vue-cli生成的项目,vue项目配置了不同开发环境的接口地址,axios.defaults.baseURL如何引用这个地址,这是在我发布项目的时候考虑的,于是想到了 方法一: config下配置文 ...
- 读取数据库信息并生成表设计文档Word版本
1.参考C#代码 using Help.DBAccessLayer.Business; using Help.DBAccessLayer.Model.SqlGenerator; using Newto ...
- 使用CMake生成sln项目和VS工程遇到的问题
用vs运行cmake后的工程 参考:http://zhidao.baidu.com/link?url=AZRxI0jGDzo6Pikk68qylee0g7leXbpbZGiVuyiijWbd8scUK ...
随机推荐
- js判断上传文件大小
下面提供三款网页特效判断上传文件大小哦,这三种方法是现在限制文件上传大小比较好的方法,可以在客户上传文件时限制上传文件大小判断处理<!doctype html public "-//w ...
- int与Integer
int 是基本类型,直接存数值 integer是对象,用一个引用指向这个对象 1.Java 中的数据类型分为基本数据类型和复杂数据类型 int 是前者>>integer 是后者(也就是一个 ...
- 《Programming Massively Parallel Processors》Chapter5 习题解答
自己做的部分习题解答,因为时间关系,有些马虎,也不全面,欢迎探讨或指出错误 5.1 Consider the matrixaddition in Exercise 3.1. Can one use s ...
- tstring
是的,一旦知道 TCHAR 和_T 是如何工作的,那么这个问题很简单.基本思想是 TCHAR 要么是char,要么是 wchar_t,这取决于 _UNICODE 的值: // abridged f ...
- python字符串连接方式(转)
在python中有很多字符串连接方式,今天就在这里具体总结一下: ①.最原始的字符串连接方式:str1 + str2②.python 新字符串连接语法:str1, str2③.奇怪的字符串方式:str ...
- LDAP 后缀操作
创建目录服务器实例之后,必须为服务器的目录信息树(Directory Information Tree,DIT)创建一个或多个后缀.DIT由服务器中的所有条目组成,这些条目使用各自的标识名(Disti ...
- mysql 在windows下的安装,开发基础与要点
1:安装(windows下) 官网下载.msi文件 运行安装时只需要安装server就行了 在环境变量中配置到bin目录:e.g:C:\programFile\...mysql\bin 完成后进入wi ...
- QQ 国际版(International version) - 关闭弹出资讯
1,打开QQ面板,点击左下角的 "企鹅"图标.选择 "Setting". 2,在弹出的 "Setting"面板中,选择 "Priv ...
- SQL存储过程笔记
一.概述 存储过程(Stored Procedure)是一组为了完成特定功能的SQL 语句集,经编译后存储在数据库.用户通过指定存储过程的名字并给出参数(如果该存储过程带有参数)来执行它. 优点: ...
- 重新认识Intent
相信android开发工程师,对Intent一定不陌生,在整个开发中随时都用到了,今天我们总结一下Intent. 1. 为什么需要Intent? 在android Intent机制是协助应用间的交互与 ...