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 ...
随机推荐
- 如何应用SPRITEKIT的CAMERA实现游戏中的ENDLESS无限循环背景
A Tutorial For How To Use SpriteKit Camera Making Endless Background Player运用Camera节点向前移动的效果 向前舞动 命为 ...
- HTML中汉字空格占位符
== 普通的英文半角空格 == == == no-break space (普通的英文半角空格但不换行) == 中文全角空格 (一个中文宽度) == == en空格 (半个中文 ...
- 利用GoAccess分析Nginx访问日志
原文链接:https://blog.csdn.net/yown/article/details/56027112 需求:及时得到线上用户访问日志分析统计结果,以便给开发.测试.运维.运营人员提供决策! ...
- thinkphp5访问sql2000数据库
大家都知道php跟mysql是绝配,但是因为有时候工作需要,要求php访问操作sql2000,怎么办呢? 一般来说有两种方式: 1. sqlsrv驱动方式 2. odbc方式 sqlsrv驱动方式,因 ...
- CentOS7 搭建GIT环境
一. 安装 libiconv 这个是非常规项 如果服务器原来已经装过 可以不装 但是如果git安装时候提示找不到libiconv 需要在git的安装参数中指定安装路径 最新版是 1.15 wget h ...
- TCC : Tiny C Compiler (2018-2-6)
饭墙下载,有缘上传: https://files.cnblogs.com/files/bhfdz/tcc-0.9.27-win32-bin.zip https://files.cnblogs.com/ ...
- java中子类会继承父类的构造方法吗?
参考: https://blog.csdn.net/wangyl_gain/article/details/49366505
- ruby中的字符串分隔符--split
当字符串是以“:”隔开时,可以这样写: column = str.split(/:/) 这样,column就是字符串每栏的值所构成的数组. eg: str = "Ruby in a shel ...
- ruby中的三目操作符和include?操作
三目操作符:口?口:口 问号前面的是布尔型的判断,true的话执行第二个方块的语句,false的话执行第三个方块的语句例如:value =(nil ? 0 : 1)p value=>1 .inc ...
- DE4加DVI子板实现静态图片显示
20170906录一下 内容后续补充