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 ...
随机推荐
- windows服务程序
首先创建一个myService的窗体程序作为服务安装卸载控制器(管理员身份运行vs,windows服务的安装卸载需要管理员权限) 在同一个解决方案里面添加一个windows服务程序,取名myWin ...
- 戴明PDCA方法
戴明PDCA方法:即Plan(计划).Do(执行).Check(检查)和Action(处理)的缩写. P(plan)计划: 包括方针和目标的确定以及活动计划的制定; D(do)执行: 执行就是具体运作 ...
- [React] React Router: Querystring Parameters
Define query param in Link, accept path and query : const Links = () => <nav > <Link to= ...
- hexo博客的优化与配置——加入统计代码
今天看着csdn博客的訪客数,就想给hexo博客也加入统计訪客的插件,上次折腾了个pacman主题,中间自带的是goole的统计,easy被墙,所以就想换一个统计工具,看了好多人用的都是cnzz的站长 ...
- 搭建Windows下Java Web开发环境
概要 1.SSH开发相关软件及开发包下载2.软件安装及相关设置3.最简单的Web程序 1.软件下载 在D盘建一个目录JavaTools,用来存放下载的软件和开发包.(本教程将使用D盘,你也可以使用 ...
- rpm软件包类型
rpm软件包 在linux世界里有两种流行的包管理方式,分别是redhat系的rpm和debian系的deb.其中rpm是RedHat Package Manager(RedHat软件包管理工具)的简 ...
- Panel( 面板) 组件 上
一. 加载方式//class 加载方式<div class="easyui-panel" data-options="closable:true"titl ...
- iOS基础框架的搭建 / 及国际化操作
1.基础框架的搭建 1.1 pod引入常用的第三方类库 1.2 创建基础文件夹结构/目录结构 Resource———存放声音/图片/xib/storyboard 等资源文件 Define——宏定义, ...
- C#Socket 案例
服务器端 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; ...
- C#list泛型集合
//创建list泛型集合 List<int> ilist = new List<int>(); ilist.Add(); ilist.Add(); ilist.AddRange ...