c# html 导出word
[CustomAuthorize]
public FileResult ExportQuestionCenterWord(SearchBaseQuestion search)
{
StringWriter strWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(strWriter);
StringBuilder sb = null;
string html = "";
try
{
search.PageSize = Int32.MaxValue;
search.Status = DeleteMarkEnum.Active;
search.isAnswer = IsAnswerEnum.Total;
search.isReview = IsReviewEnum.Total;
search.AddOrderBy("MODIFYDATE", SearchOrderType.Desc);
if (search.SOURCE == "0")
search.SOURCE = "";
if (search.MODULE == "0")
search.MODULE = "";
if (search.QUESTIONTYPE == "0")
search.QUESTIONTYPE = "";
if (search.QSTATUS == "0")
search.QSTATUS = "";
if (search.ADMINID == "0")
search.ADMINID = "";
if (!string.IsNullOrEmpty(search.IsSaleQuestion) && search.IsSaleQuestion == "1")
search.CUSTOMERMANAGERIDs = GetInPermissionCustomerMannagerIDs();
IList<BASE_QUESTION> baseQuestionList = questionManager.SearchQuestionList(search);
IList<BASE_CHOICECUSTOMERMANAGER> managerList = customerManagerService.GetChoiceCusManageList();
SearchChoiceCusManager search_msg = new SearchChoiceCusManager();
search_msg.SearchType = SearchTypeEnum.Total;
search_msg.Status = DeleteMarkEnum.Active;
search_msg.parentIdMany = "samedatakefu";
IList<BASE_CHOICECUSTOMERMANAGER> choiceManagerList = choiceCusManagerManager.Search(search_msg);
if (baseQuestionList.Count > 0)
{
foreach (var baseQuestion in baseQuestionList)
{
//获取受理人
string ADMINID_Str = "";
if (choiceManagerList != null && choiceManagerList.Count > 0)
{
BASE_CHOICECUSTOMERMANAGER em = choiceManagerList.Where(m => m.USERID == baseQuestion.ADMINID).FirstOrDefault();
if (em != null)
{
ADMINID_Str = em.NAME;
}
}
BASE_CHOICECUSTOMERMANAGER manager = managerList.FirstOrDefault(t => t.ID == baseQuestion.CUSTOMERMANAGERID);
string strSource = string.Empty;
switch (baseQuestion.SOURCE)
{
case 1:
strSource = "QQ";
break;
case 2:
strSource = "Email";
break;
case 3:
strSource = "Online";
break;
case 4:
strSource = "Sales";
break;
case 5:
strSource = "用户直通车";
break;
case 6:
strSource = "需求直通车";
break;
case 7:
strSource = "回访";
break;
case 8:
strSource = "QQ群";
break;
case 9:
strSource = "社区";
break;
case 10:
strSource = "微信群";
break;
default:
strSource = "全部";
break;
}
sb = new StringBuilder();
sb.Append("<table border='1' cellspacing='0' style=\"width;1200px;\">");
sb.Append("<tbody>");
//第一行
sb.Append("<tr align='center'>");
sb.Append("<td colspan='3' style='width:1200px;'>");
sb.Append(baseQuestion.TITLE == null ? StringConst.NAConst : baseQuestion.TITLE);
sb.Append("</td>");
sb.Append("</tr>");
//第二行
BASE_USER user = userManager.GetUserByUniqueId(baseQuestion.USERID);
if (user == null)
user = new BASE_USER();
sb.Append("<tr>");
sb.Append("<td style='width:400px;'>");
sb.Append("姓名:" + user.REALNAME);
sb.Append("</td>");
sb.Append("<td style='width:400px;'>");
sb.Append("账号:" + baseQuestion.USERNAME);
sb.Append("</td>");
sb.Append("<td style='width:400px;'>");
sb.Append("联系方式:" + baseQuestion.MOBILE);
sb.Append("</td>");
sb.Append("</tr>");
//第三行
sb.Append("<tr>");
sb.Append("<td style='width:400px;'>");
sb.Append("模块:" + (string.IsNullOrEmpty(baseQuestion.MODULE) ? "" : packageTreeCopy.GetOneById(baseQuestion.MODULE) == null ? "" : packageTreeCopy.GetOneById(baseQuestion.MODULE).FULLNAME));
sb.Append("</td>");
sb.Append("<td style='width:400px;'>");
sb.Append("问题类型:" + AttributesUtils.GetEnumDescription<QuestionCenterTypeEnum>(baseQuestion.QUESTIONTYPE));
sb.Append("</td>");
sb.Append("<td style='width:400px;'>");
sb.Append("状态:" + AttributesUtils.GetEnumDescription<QuestionCenterStatusEnum>(baseQuestion.STATUS));
sb.Append("</td>");
sb.Append("</tr>");
//第四行
sb.Append("<tr>");
sb.Append("<td style='width:400px;'>");
sb.Append("受理人:" + ADMINID_Str);
sb.Append("</td>");
sb.Append("<td style='width:400px;'>");
sb.Append("产品对接人:" + baseQuestion.PRODUCTMANAGERNAME);
sb.Append("</td>");
sb.Append("<td style='width:400px;'>");
sb.Append("下次跟踪时间:" + (baseQuestion.NEXTVIEWDATE.ToString() == "0001-01-01 00:00:00" ? "" : baseQuestion.NEXTVIEWDATE.ToString()));
sb.Append("</td>");
sb.Append("</tr>");
//第五行
sb.Append("<tr>");
sb.Append("<td style='width:400px;'>");
sb.Append("标签:" + baseQuestion.KEYWORD);
sb.Append("</td>");
sb.Append("<td colspan='2' style='width:800px;'>");
sb.Append("来源:" + strSource);
sb.Append("</td>");
sb.Append("</tr>");
//第六行
sb.Append("<tr'>");
sb.Append("<td colspan='3' style='width:1200px;'>");
sb.Append("内容:" + baseQuestion.CONTENT);
sb.Append("</td>");
sb.Append("</tr>");
//第七行
string questionID = baseQuestion.ID.ToString();
BASE_ANSWER answer = answerManager.GetAnswerByQuestionsID(questionID);
sb.Append("<tr'>");
sb.Append("<td colspan='3' style='width:1200px;'>");
sb.Append("回复:" + (answer == null ? "" : HtmlDecode(answer.CONTENT)));
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("</tbody>");
sb.Append("</table>");
sb.Append("<br/>");
sb.Append("<br/>");
html += sb.ToString();
}
strWriter.Write(html);
}
else
{
strWriter.WriteLine("没有数据!");
}
}
catch (Exception ex)
{
LogHelper.Instance.Error("ExportQuestionCenterWord error:", ex);
strWriter.WriteLine("导出出现问题:" + ex.Message);
}
byte[] fileContents = Encoding.GetEncoding("gb2312").GetBytes("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"><body>" + strWriter.ToString() + "</body></html>");
return File(fileContents, "application/vnd.ms-word", string.Format("{0}.doc", "问题中心" + DateTime.Now.Date.ToString("yyyyMMdd")));
}
c# html 导出word的更多相关文章
- java 导出word 并下载
记录一下导出操作 源码: /************ * 导出word 并下载 * @param id 房号记录编号 * ***********************/ @RequestMappin ...
- Asp.net通过模板(.dot/Html)导出Word,同时导出图片
一.Office组件导出Word(服务器配置麻烦) 需要引用Office的DLL,在下文的附件中,不同的Offic版本用的不一样,虽然高级版本可以兼容低级的,不过,还是统一版本最好 贴上核心代码(转载 ...
- 导出Excel And 导出word
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx. ...
- 使用NPOI2.1.3.1版本导出word附带表格和图片
原文:http://www.cnblogs.com/afutureBoss/p/4074397.html?utm_source=tuicool&utm_medium=referral 最近项目 ...
- Java使用velocity导出word
效果展示: 使用word编辑好模板
- 【吉光片羽】MVC 导出Word的两种方式
1.直接将Html转成Word.MVC自带FileResult很好用.Html中我们也可以嵌入自己的样式. html: <div id="target"> <st ...
- java导出word的6种方式(复制来的文章)
来自: http://www.cnblogs.com/lcngu/p/5247179.html 最近做的项目,需要将一些信息导出到word中.在网上找了好多解决方案,现在将这几天的总结分享一下. 目前 ...
- 【MVC】 非常简单的页面导出 WORD, EXCEL方法
[MVC] 页面导出 WORD, EXCEL 前端 js function output() { var para = new Object(); para.html = getHtml(" ...
- 网页内容导出word/excel的js代码
IE设置: 工具-> Internet选项-> 安全->自定义级别-> 对没有标记安全级别的ActiveX控件进行初始化 设为启用! 1.导出word //指定区域导出到Wo ...
- MVC4 导出word
添加程序包 DocX using System.IO;using Novacode; /// <summary> /// 导出Word /// </summary> publi ...
随机推荐
- Cocopods Search失败的坑
最近看了下如何使用cocopods来制作自己的公有库,然后果断的按照教程做了一遍,然后提交审核.完成之后意外的发现使用pod search xxx的时候报了一大堆的日志出来,pod的其他功能可以使用, ...
- word 或者 WPS 使用两个目录的时候去掉中间的空格间隙
在生成图表目录时,发现Office word图表目录中多个标题之间的空行无法删除,我是自己建的标签,比如“图1-”.“图2-”…….“表1-”.“表2-”…… 发现“图1-”.“图2-”…….“表1- ...
- Flask之蓝图的使用
蓝图,听起来就是一个很宏伟的东西 在Flask中的蓝图 blueprint 也是非常宏伟的 它的作用就是将 功能 与 主服务 分开怎么理解呢? 比如说,你有一个客户管理系统,最开始的时候,只有一个查看 ...
- Python基础、条件语句和基本数据类型
1. 第一句python - 后缀名是可以是任意? - 导入模块时,如果不是.py文件 ==> 以后文件后缀名是 .py 2. 两种执行方式 python解释器 py文件路径 python 进入 ...
- ruby中的extend 和 include
include include是把module中定义的instance_method给mixin,然后当做类的实例方法使用(是因为module本身不能使用module的实例方法),给类进行实例化一个对 ...
- ACM1004:Let the Balloon Rise
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- (转载)PHP环境搭建-记录
PHP环境搭建-记录 转于 http://jingyan.baidu.com/article/fcb5aff797ec41edaa4a71c4.html php5.5 做了大量的更新,在与apac ...
- mybatis中的resultMap实际作用
resultMap和resultType在实际的使用上完全可以进行替换,但是resultMap有比resultType更多的一个功能.我们先定义一个简单的resultMap例子 <resultM ...
- MongoDB入门---文档查询操作之条件查询&and查询&or查询
经过前几天的学习之路,今天终于到了重头戏了.那就是文档查询操作.话不多说哈,直接看下语法: db.collection.find(query, projection) query :可选,使用查询操作 ...
- 北京Uber优步司机奖励政策(3月19日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...