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 ...
随机推荐
- android后台截屏实现(3)--编译screencap
修改好之后就要编译了,screencap的编译是要在源码环境中进行的. 将修改后的screencap.cpp文件替换源码中的原始文件,然后修改screencap的Android.mk文件,修改后的文件 ...
- NuGet学习笔记(2)——使用图形化界面打包自己的类库
上文NuGet学习笔记(1) 初识NuGet及快速安装使用说到NuGet相对于我们最重要的功能是能够搭建自己的NuGet服务器,实现公司内部类库的轻松共享更新.在安装好NuGet扩展后,我们已经能够通 ...
- [转]Android 网络通信框架Volley简介(Google IO 2013)
Volley主页 https://android.googlesource.com/platform/frameworks/volley http://www.youtube.com/watch?v= ...
- Web Service那点事
出现 如今基于浏览器的client应用程序越来越流行,而从开发角度来看,一方面是client浏览器的安装配置不再须要我们再去花费非常大的精力.还有一方林则是由于client和server之间通信的问题 ...
- 3D空间包围球(Bounding Sphere)的求法
引言 在3D碰撞检測中,为了加快碰撞检測的效率,降低不必要的碰撞检測,会使用基本几何体作为物体的包围体(Bounding Volume, BV)进行測试.基本包围体的碰撞检測相对来说廉价也easy的多 ...
- mybatis简单应用(基于配置文件)
本文主要介绍了如何使用mybatis进行简单的数据库操作.本人使用的是mybatis3.05. 1.创建数据库表(User表) CREATETABLE `NewTable` (`userId` big ...
- [Angular 2] Transclusion in Angular 2
Link: Blog Single transclude: <ng-content></ng-content> Multi-translcude: <ng-content ...
- OD: Memory Attach Technology - Exception
看到第六章了:形形色色的内存攻击技术 异常处理结构体 S.E.H Structure Exception Handler S.E.H 是 Windows 处理异常的重要数据结构.每个 S.E.H 为 ...
- hdu 2013
水题 AC代码: #include <iostream> using namespace std; int main() { int i,m,n; while(cin>>n) ...
- IE9的window.showmodaldialog显示问题
<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat=&quo ...