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 ...
随机推荐
- BNU10804:域名统计
域名(Domain Name),是由一串用点分隔的名字组成的Internet上某一台计算机或计算机组的名称,用于在数据传输时标识计算机的电子方位(有时也指地理位置),目前域名已经成为 互联网的品牌.网 ...
- Mysql数据库的mysql Schema 究竟有哪些东西& 手工注入的基础要领
#查看数据库版本号 mysql> select @@version; +------------+ | @@version | +------------+ | 5.5.16-log | +- ...
- inode-软链接与硬链接
一.inode是什么?理解inode,要从文件储存说起.文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sector).每个扇区储存512字节(相当于0.5KB).操作系统读取硬 ...
- (转)检测到在集成的托管管道模式下不适用的ASP.NET设置的解决方法(转)
我们将ASP.NET程序从IIS6移植到IIS7,可能运行提示以下错误: HTTP 错误 500.23 - Internal Server Error 检测到在集成的托管管道模式下不适用的 ASP.N ...
- svn服务器的配置步骤
1.安装客户端: TortoiseSVN-1.9.3.27038-x64-svn-1.9.3.msi下载地址:http://jaist.dl.sourceforge.net/project/torto ...
- ArcGIS Server 9.3 安装(win7).
概述: 安装的过程还不算复杂,但是有个地方需要注意:就是防火墙.需要将 "本机的防火墙" 关掉, 并将 "杀毒软件关闭"(360和avira都会乱来,搞得我安了 ...
- [C#]asp.net开发微信公众平台----目录汇总-持续更新
1.[c#]asp.net微信公众平台开发(1)数据库设计 2.[c#]asp.net微信公众平台开发(2)多层架构框架搭建和入口实现 3.[c#]asp.net微信公众平台开发(3)微信消息封装及反 ...
- C#多线程实践——线程同步
下面的表格列展了.NET对协调或同步线程动作的可用的工具: 简易阻止方法 构成 目的 Sleep 阻止给定的时间周期 Join 等待另一个线程完成 ...
- Java系列--第七篇 基于Maven的Android开发实战项目
本篇是基于<Android应用案例开发大全,吴亚峰等著>的项目开发实例源码,其中有些图片,我做了一些修改,用于个人学习,请勿用于商业. 1, 日程管理专家 mvn archetype:ge ...
- php 之 文件上传(0523)
如何上传图片: 上传页面: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http ...