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 ...
随机推荐
- OC - ARC(自动引用计数)
1.什么是自动引用计数? 顾明思义,自动引用计数(ARC,Automatic Reference Counting)是指内存管理中对引用采取自动计数的技术. 在OC中采用ARC机制,让编译器来进行内存 ...
- Matlab 编程入门(一):编程基础
上学期学了一些matlab的知识,这学期再用时竟然发现已经忘得差不多了(┬_┬) 于是决定重新开始并将它们记录下来,也方便自己以后查漏补缺! M文件编程 脚本文件 matlab有自己的命令行窗口,对于 ...
- 编写radware的负载配置
radware如何添加负载服务? 笔者在新添加radware的新负载服务的时候,是习惯去看下上一个负载服务的ID 和 节点服务的ID 号 分别是多少,主要是避免ID冲突,把其他服务顶替下去,同时以后这 ...
- CentOS7 LNMP+phpmyadmin环境搭建(一、虚拟机及centos7安装)
前一阵子配公司的服务器的时候,发现网上好多教程杂乱无章,然后便根据网上已有资料自己整理了一个lnmp环境的安装教程.因为懒,已经好久没写过博客了.趁着这次公司招新人,把之前整理的文档又整理了一次,顺便 ...
- lamp 安装 apache
lamp安装 httpd-2.2.4.tar.gz :http://download.csdn.net/detail/wulvla020311/8046141 先检查一下装的东西都在不在:rpm -q ...
- 网站用户行为分析——Linux的安装
Linux的选择 在Linux系统各个发行版中,CentOS系统和Ubuntu系统在服务端和桌面端使用占比最高,网络上资料最是齐全,所以建议使用CentOS系统或Ubuntu. 一般来说,如果要做服务 ...
- 【Android】添加依赖包
貌似好像不知一种方法,以后有时间再研究,下面是其中的一种方法
- [STM32F4][关于看门狗的那些事]
STM32(stm32f4XX系列)看门狗的总结: 1. 具有两个看门狗外设(独立和窗口)均可用于检测并解决由软件错误导致的故障:当计数器达到给定的超时值时,触发一个中断(仅适用于窗口看门狗)或产生一 ...
- python3 package management 包管理 实例
包是一种组织管理代码的方式,包里面存放的是模块 用于将模块包含在一起的文件夹就是包 包内包含__init__.py标志性文件 定义一个学生类,一个sayhello函数,一个打印语句 # p01.py ...
- spark ---词频统计(二)
利用python来操作spark的词频统计,现将过程分享如下: 1.新建项目:(这里是在已有的项目中创建的,可单独创建wordcount项目) ①新建txt文件: wordcount.txt (文件内 ...