.Net实现Word文档及导出
参考网址:
http://www.jb51.net/article/25062.htm(实用性)
http://www.csharpwin.com/dotnetspace/12470r7724.shtml
http://bbs.csdn.net/topics/220001707(各文本加入)
WORD文档保存后,获取并现在已保存文档。
string path = AppDomain.CurrentDomain.BaseDirectory + ("UpFiles\\") + fileName;
return File(new FileStream(path, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite), "image/jpeg jpeg jpg jpe", fileName);
此处加入:System.IO.FileAccess.Read, FileShare.ReadWrite 文档流只读,文档共享读写操作。可避免如下错误提示
...文本正由另一进程使用,因此该进程无法访问该文件
=================
/// <summary>
/// 新建Word文档
/// </summary>
/// <param name="path">文件路径</param>
/// <param name="strContent">文件内容</param>
public void CreateWordFile(string path, string strContent)
{ MSWord.Application wordApp;
//C#创建Word文档之word应用程序 MSWord.Document wordDoc;//word文档 wordApp = new MSWord.Application(); if (File.Exists(path))
{ File.Delete(path); } object filePath = path;
Object nothing = Missing.Value; wordDoc = wordApp.Documents.Add(
ref nothing, ref nothing, ref nothing, ref nothing); wordApp.Visible = false; wordDoc.Paragraphs.Last.Range.Text = strContent; object format = MSWord.WdSaveFormat.wdFormatDocumentDefault; wordDoc.SaveAs(ref filePath, ref format,
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); wordDoc.Close(ref nothing, ref nothing, ref nothing); wordApp.Quit(ref nothing, ref nothing, ref nothing);
}
.Net实现Word文档及导出的更多相关文章
- word文档的导出(用freemarker模板导出)(桃)
1.将要导出的word文档另存为xml格式的 2.用文档编辑器打开(如:notepad++),将要展示的数据用${name}的形式替换,“name”对应数据库中的字段 3.根据模板生成 package ...
- C#使用NPOI对Word文档进行导出操作的dll最新版2.5.1
Npoi导出非模板 最近使用NPOI做了个导出Word文档的功能,因为之前都是导出Excel很方便(不用模板),所以导出Word也选用了Npoi(也没有用模板,
- MindManager导出Word文档功能介绍
Mindmanager思维导图软件作为一款能与Microsoft office软件无缝集成的思维导图软件,支持Word文档的快速导入与导出,并支持Word文档的目录生成.模板套用等,极大地方便了用户完 ...
- 可以把思维导图导出为word文档方便其他人查看吗?
MindManager除了强大的大纲视图编辑功能外,还拥有多种导出格式,方便大家迅速导出文件,在团队中分享自己的观点,提高团队的工作效率,本次小编使用的思维导图软件版本是MindManager 202 ...
- powerdesigner连接postgresql数据库生成pdm及word文档
1.准备软件: powerdesigner165与postgresql的驱动:psqlodbc_11_01_0000 2.安装并破解完成powerdesigner165 参看链接:https://ww ...
- java 导出数据为word文档(保持模板格式)
导出数据到具体的word文档里面,word有一定的格式,需要保持不变 这里使用freemarker来实现: ①:设计好word文档格式,需要用数据填充的地方用便于识别的长字符串替换 如 aaaaa ...
- 批量导出access某表内容到word文档
一.需求: 需要将表中每一条记录中的某些内容导出在一个word文档中,并将这些文档保存在指定文件夹目录下 二.界面,简单设计如下: 三.添加office相关引用 添加后可在解决方案资源管理器中看到: ...
- 把word文档中的所有图片导出
把word文档中的所有图片导出 end
- asp.net 将word文档进行编辑并导出一个新的word
最近做项目,需要多word文档进行编辑并导出一个新的word,在最初的word编辑中留下特定的字符串用来替换,然后在本地生成一个新的word文档,并且不修改服务器中的word文档,这样才能保证服务器中 ...
随机推荐
- Flutter Stack布局中定位的方式
前言 想要记录一下Stack布局中,定位的两种方式 代码 //……省略无关代码…… child: new Column( children: <Widget>[ new SizedBox( ...
- UserInfoActivity用户图像修改和退出登录
@OnClick(R.id.btn_user_logout) public void logout(View view){//"退出登录"button的回调方法 //1.将保存在s ...
- oracle 用户创建、修改、删除
创建用户: create user test identified by test; 修改密码: 1.alter user test identified by mima; 2.passw[ord] ...
- 用JS实现的常见几种排序算法
1.快速排序法 function quickSort(a) { if (a.length <= 1) { return a; } var midLength = Math.floor(a.len ...
- winform listbox 使用DrawMode使用OwnerDrawVarialbe或OwnerDrawFixed无水平滚动条
因为需要使用DrawMode自行DrawItem,所以需要将DrawMode设置为OwnerDrawVarialbe或OwnerDrawFixed模式,代码如下: private void listB ...
- 回归JavaScript基础(七)
主题:引用类型Function的介绍. 今天首先说的就是Function类型.下面就是定义函数的两种方法,第一种使用函数声明语法定义,第二种使用函数表达式定义.这两种定义函数的方式几乎没有什么区别. ...
- clean-css
What is clean-css? Clean-css is a fast and efficient Node.js library for minifying CSS files. Accord ...
- Oracle EBS 配置文件取值
SELECT op.profile_option_id, tl.profile_option_name, tl.user_profile_option_name, lv.level_id, lv.文件 ...
- Vue2学习笔记:组件(Component)
组件 组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.在较高层面上,组件是自定义元素, Vue.js 的编译器为它添加特殊功能.在有些情况 ...
- [WinCE] Can't find P/Invoke DLL sqlceme35.dll
找到目录: C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Devices\wce500\armv4i 将 sqlce ...