星空网 > 软件开发 > ASP.net

C# 生成表格代碼

 public ActionResult btnExport(ReportViewModel model)         {             //接收需要导出的数据             List<ReportViewModel.EmployeeRegister> list = EmployeeRepository.GetEmployeePrportAll(model).ToList();

            //命名导出表格的StringBuilder变量             StringBuilder sHtml = new StringBuilder(string.Empty);

            //打印表头             sHtml.Append("<table border=\"1\" width=\"100%\">");                         //打印列名             sHtml.Append("<tr height=\"20\" align=\"center\" >"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">序号</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">工号</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">姓名</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">性别</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">部门</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">公司补助</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">实用补助</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">出游时间</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">线路</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">旅行社</td>"                         + "<td style=\"background-color:#4474BB;font-weight:bold\">签到处</td>"                         + "</tr>");

            //循环读取List集合             for (int i = 0; i < list.Count; i++)             {                 sHtml.Append("<tr height=\"20\" align=\"left\">"                         + "<td>" + list[i].ListIndex + "</td>"                         + "<td>" + list[i].EmployeeNo + "</td>"                         + "<td>" + list[i].EmployeeNm + "</td>"                         + "<td>" + list[i].SexCN + "</td>"                         + "<td>" + list[i].Dept + "</td>"                         + "<td style=\"color:Red\">" + list[i].Subsidy + "</td>"                         + "<td style=\"color:Red\">" + list[i].UseSubsidy + "</td>"                         + "<td>" + list[i].GroupDt + "</td>"                         + "<td>" + list[i].ProductNm + "</td>"                         + "<td>" + list[i].AgenciesNm + "</td>"                         + "<td></td>"                         + "</tr>");             }

            //打印表尾             sHtml.Append("</table>");

            System.Web.HttpContext.Current.Response.Charset = "UTF-8";             System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;             System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("津贴使用報表.xls", System.Text.Encoding.UTF8).ToString());             System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";             System.IO.StringWriter tw = new System.IO.StringWriter();             System.Web.HttpContext.Current.Response.Output.Write(sHtml.ToString());             System.Web.HttpContext.Current.Response.Flush();             System.Web.HttpContext.Current.Response.End();

   return File(sHtml.ToString(), "attachment;filename=津贴使用報表.xls");         }




原标题:C# 生成表格代碼

关键词:C#

C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

VAT申请的全流程指南从申请到审核的一步步操作:https://www.kjdsnews.com/a/1339067.html
VAT税制介绍增值税的计算机制:https://www.kjdsnews.com/a/1339068.html
VAT税制一个完整的读书指南:https://www.kjdsnews.com/a/1339069.html
VAT码的申请与使用指南:https://www.kjdsnews.com/a/1339070.html
VAT码全球增值税代码的重要性:https://www.kjdsnews.com/a/1339071.html
VAT的读音及其含义详细剖析:https://www.kjdsnews.com/a/1339072.html
23点聊电商:新质生产力加速数字贸易发展 卓尔智联集团实现营收利润双增长 :https://www.kjdsnews.com/a/1836411.html
南京浦口都有什么好玩的地方 南京浦口都有什么好玩的地方推荐:https://www.vstour.cn/a/363180.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流