国产探花免费观看_亚洲丰满少妇自慰呻吟_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"); }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乐业县| 马关县| 铜川市| 婺源县| 湘阴县| 手游| 博客| 鄂温| 建湖县| 庄浪县| 钟山县| 六盘水市| 婺源县| 晋城| 凤庆县| 资中县| 信丰县| 琼中| 镇康县| 望奎县| 亚东县| 阜宁县| 浮山县| 偃师市| 刚察县| 通辽市| 广东省| 萨嘎县| 银川市| 云阳县| 阿瓦提县| 泰来县| 罗源县| 九江市| 金门县| 长宁县| 麻栗坡县| 象州县| 观塘区| 海晏县| 商洛市|