controller

 1 using Aspose.Words;
2 using Aspose.Words.Saving;
3 using System.IO;
4
5
6 ///
7 /// 获取导入Word 文档
8 ///
9 ///
10 ///
11 public ActionResult GetWord(int PaperId)
12 {
13 try
14 {
15 var __data = _paperApp.GetWord(PaperId);
16 string tempPath = Server.MapPath("~/Template/导出模版.docx");
17 string outputPath = Server.MapPath("~/Resources/Output/模版_temp.doc");
18 //载入模板
19 var doc = new Document(tempPath);
20 //提供数据源
21 String[] fieldNames = new String[] { "PaperName", "PaperTypeName", "SingleChoiceCount", "SingleChoiceScore", "SingleChoiceContent",
22 "MultipleChoiceCount", "MultipleChoiceScore", "MultipleChoiceContent", "TrueFalseCount", "TrueFalseScore", "TrueFalseContent" };
23 Object[] fieldValues = new Object[] { __data.PaperName, __data.PaperTypeName, __data.SingleChoiceCount, __data.SingleChoiceScore, __data.SingleChoiceContent,
24 __data.MultipleChoiceCount, __data.MultipleChoiceScore, __data.MultipleChoiceContent, __data.TrueFalseCount, __data.TrueFalseScore, __data.TrueFalseContent };
25 //合并模版,相当于页面的渲染
26 doc.MailMerge.Execute(fieldNames, fieldValues);
27 //保存合并后的文档
28 doc.Save(outputPath);//在MVC中采用,保存文档到流中,使用base.File输出该文件
29 var docStream = new MemoryStream();
30 doc.Save(docStream, SaveOptions.CreateSaveOptions(SaveFormat.Doc));
31 return base.File(docStream.ToArray(), "application/msword", "试卷" + __data.PaperName + ".doc");
32 }
33 catch (Exception ex)
34 {
35 return Error(ex.Message);
36 }
37 }
我会经常修改 不希望被转载!

.net MVC使用Aspose.Words 获取文本域获取文档的更多相关文章

  1. 通过Html5的postMessage和onMessage方法实现跨域跨文档请求访问

    在项目中有应用到不同的子项目,通过不同的二级域名实现相互调用功能.其中一个功能是将播放器作为单独的二级域名的请求接口,其他项目必须根据该二级域名调用播放器.最近需要实现视频播放完毕后的事件触发,调用父 ...

  2. 用VC++MFC做文本编辑器(单文档模式)

    用VC++MFC做文本编辑器(单文档模式) 原来做过一个用对话框实现的文本编辑器,其实用MFC模板里面的单文档模板也可以做,甚至更加方便,适合入门级的爱好者试试,现介绍方法如下: < xmlna ...

  3. Taurus.MVC WebAPI 入门开发教程8:WebAPI文档与自动化测试。

    系列目录 1.Taurus.MVC WebAPI  入门开发教程1:框架下载环境配置与运行. 2.Taurus.MVC WebAPI 入门开发教程2:添加控制器输出Hello World. 3.Tau ...

  4. Aspose.Words操作word生成PDF文档

    Aspose.Words操作word生成PDF文档 using Aspose.Words; using System; using System.Collections.Generic; using ...

  5. mongoDB 获取最后插入的文档的ObjectID/_id方法

    http://stackoverflow.com/questions/3338999/get-id-of-last-inserted-document-in-a-mongodb-w-java-driv ...

  6. 倒排索引 获取指定单词的文档集合 使用hash去重单词term 提高数据压缩率的方法

    倒排索引源于实际应用中需要根据属性的值来查找记录.这种索引表中的每一项都包括一个属性值和具有该属性值的各记录的地址.由于不是由记录来确定属性值,而是由属性值来确定记录的位置,因而称为倒排索引(inve ...

  7. ASPOSE.Cells & ASPOSE.Words 操纵Excel和Word文档的 .NET Core 实例

    Aspose.Total是Aspose公司旗下的最全的一套office文档管理方案,它提供的原生API可以对Word.Excel.PDF.Powerpoint.Outlook.CAD.图片.3D.ZI ...

  8. java利用Aspose.slides.jar将本地ppt文档转化成pdf(完美破解版 无水印 无中文乱码)

    下载aspose.slides-15.9.0.jar包 http://pan.baidu.com/s/1jH3ZNbK JAVA代码 package webViewer; import java.io ...

  9. 利用Aspose.Word控件实现Word文档的操作

    Aspose系列的控件,功能都挺好,之前一直在我的Winform开发框架中用Aspose.Cell来做报表输出,可以实现多样化的报表设计及输出,由于一般输出的内容比较正规化或者多数是表格居多,所以一般 ...

随机推荐

  1. vue的登陆验证及返回登录前页面实现

    一.路由配置部分如下所示, 导出路由示例 let router = new VueRouter({ routes: [ // 登陆 { name: 'login', path: '/login', c ...

  2. icpc2018焦作-I. Distance

    第一发又超时了... 题目大意:给你n个点,然后给你n-1的数,表示两两距离,然后让你输出n个答案,第i个答案表示从这n个点里面挑i个点,然后这i个点两两之间会有一个距离,答案要求这些距离和的最大值. ...

  3. 性能测试学习 第九课--LR12中controller基础知识

    1.设计手工场景,理解集合点的策略 2.添加load generator 一.controller基础知识 1.controller的原理 通过场景设计来模拟用户的真实操作并调用vugen中的脚本,然 ...

  4. RHEL7 配置网络yum源

    redhat系统安装好尽管默认带有yum,但是redhat的更新包只对注册用户有效(收费).所以需要更换yum源. 基本的流程就是: 1.删除redhat7.0系统自带的yum软件包: 2.自行下载所 ...

  5. Rewrite JSON project with Fetch

    上传 JSON 数据 使用fetch()来发布json编码的数据. var url = 'https://example.com/profile'; var data = {username: 'ex ...

  6. TCP的三次握手过程与四次挥手

    TCP握手协议 在TCP/IP协议中,TCP协议提供可靠的连接服务,采用三次握手建立一个连接.第一次握手:建立连接时,客户端发送syn包(syn=j)到服务器,并进入SYN_SEND状态,等待服务器确 ...

  7. [Swift]LeetCode583. 两个字符串的删除操作 | Delete Operation for Two Strings

    Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 t ...

  8. [Swift]LeetCode722. 删除注释 | Remove Comments

    Given a C++ program, remove comments from it. The program source is an array where source[i] is the  ...

  9. [Swift]LeetCode799. 香槟塔 | Champagne Tower

    We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so ...

  10. the python challenge闯关记录(0-8)

    0 第零关 2**38 = 274877906944 下一关的url:http://www.pythonchallenge.com/pc/def/274877906944.html 1 第一关 移位计 ...