国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

C# 生成表格代碼

2019-11-17 02:13:09
字體:
來源:轉載
供稿:網友

C# 生成表格代碼

Posted on 2015-07-29 17:16 qhy1277 閱讀(...) 評論(...) 編輯 收藏

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"); }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 福清市| 永顺县| 新和县| 宜兴市| 杂多县| 方正县| 镇沅| 长宁县| 武邑县| 友谊县| 南雄市| 冷水江市| 会理县| 江陵县| 横峰县| 文水县| 景泰县| 东方市| 温宿县| 克拉玛依市| 特克斯县| 南昌市| 萍乡市| 阿城市| 长寿区| 吉木乃县| 泸水县| 张家口市| 盐津县| 密山市| 山阳县| 巴林左旗| 上饶县| 玉山县| 抚顺市| 澎湖县| 桂阳县| 乐昌市| 仙桃市| 新余市| 宜兰县|