惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - stonespawn

Vue 组件库2 Vue 的组件库 算法小题目 VS2019 自动代码补全功能 GIT 删除操作 vue-router 注意事项 Vue中axios访问 后端跨域问题 Vue2.0 搭配 axios Vue 脚手架搭建 grunt使用入门 Git相关操作及记录 Ajax在调用含有SoapHeader的webservice方法 关于JS 树形结构 链接点击跳动问题 WatiN——Web自动化测试(三)【弹出窗口处理】 WatiN——Web自动化测试(二) WatiN——Web自动化测试(一) 网页调用服务程序 - stonespawn - 博客园 小问题 小技巧 :创建虚拟目录并将IIS里面.net配置版本设为2.0 - stonespawn
导出EXCEL【Web方式HTML通过拼接html中table】
stonespawn · 2013-09-27 · via 博客园 - stonespawn

DataTable dt= GetTaskList(int.MaxValue);

            StringBuilder table = new StringBuilder();

            table.Append("<meta http-equiv=\"content-type\" content=\"application/ms-excel; charset=UTF-8\"/>"); 

       //在拼接table时,需要加入这句,否则会出现乱码

            table.Append("<table cellpadding='1' cellspacing='1' style='width:1200px; background:#CCCCCC;font-size:13px;'>");

            table.Append("<tr>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>酒店ID</td>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>酒店名称</td>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>检查人</td>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>开始日期</td>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>结束日期</td>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>自查日期</td>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>整改日期</td>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>复核日期</td>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>类型</td>");

            table.Append("<td style='background:#666666; height:25px; color:#FFF; font-weight:bold; text-align:center;'>状态</td>");

            table.Append("</tr>");

            foreach (DataRow dr in dt.Rows)

            {

                table.Append("<tr>");

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", dr["HotelID"]);

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", dr["HotelName"]);

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", dr["CheckUser"]);

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", HotelInspection.Component.CommonUtility.StrToDateTime(dr["BeginDate"]).ToString("yyyy-MM-dd"));

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", HotelInspection.Component.CommonUtility.StrToDateTime(dr["EndDate"]).ToString("yyyy-MM-dd"));

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", HotelInspection.Component.CommonUtility.StrToDateTime(dr["CheckSumbitDate"]).ToString("yyyy-MM-dd"));

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", HotelInspection.Component.CommonUtility.StrToDateTime(dr["RectifySumbitDate"]).ToString("yyyy-MM-dd"));

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", HotelInspection.Component.CommonUtility.StrToDateTime(dr["ReviewSumbitDate"]).ToString("yyyy-MM-dd"));

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", dr["TaskFrom"]);

                table.AppendFormat("<td style='background:#FFFFFF; height:25px;'>{0}</td>", dr["TaskStatus"]);

                table.Append("</tr>");

            }

            table.Append("</table>");

            string filename = DateTime.Now.ToString("yyyyMMddHHmmss")+".xls";

            HttpContext.Current.Response.Clear();

            HttpContext.Current.Response.Buffer = true;

            HttpContext.Current.Response.Charset = "UTF-8";

            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=\"" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8) + "\"");

            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;

            HttpContext.Current.Response.HeaderEncoding = System.Text.Encoding.UTF8;

            HttpContext.Current.Response.ContentType = "application/ms-excel;";

            HttpContext.Current.Response.Write(table.ToString());

            HttpContext.Current.Response.End();