| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Text;
- namespace HySoft.BaseCallCenter.Web.reportmanage
- {
- public partial class ExecutionEfficiency : System.Web.UI.Page
- {
- protected string TableTitle = null;
- protected string TableOne = null;
- protected string TableTwo = null;
- protected string TableHtml = null;
- protected void Page_Load(object sender, EventArgs e)
- {
- #region Demo
- //PrintTable();
- //string[] head = { "日期", "工单总量", "工单总用时", "工单平均用时", "指派总用时", "指派平均用时", "接单总用时", "接单平均用时", "处理总用时", "处理平均用时", "回访总用时", "回访平均用时", "结单总用时", "结单平均用时" };
- //string[,] body = new string[30, 14];
- //for (int i = 0; i < 30; i++)
- //{
- // for (int j = 0; j < 14; j++)
- // {
- // if (j == 0)
- // body[i, j] = "2015/4/" + (i + 1).ToString();
- // else body[i, j] = "";
- // }
- //}
- //string[] sumiteam = { "合计:", "工单总量", "工单总用时", "工单平均用时", "指派总用时", "指派平均用时", "接单总用时", "接单平均用时", "处理总用时", "处理平均用时", "回访总用时", "回访平均用时", "结单总用时", "结单平均用时" };
- //TableHtml = createTableTitle("工单流程执行效率") + createTable1(head, body, sumiteam);
- #endregion
- OutputTable();
- }
- private void OutputTable()
- {
- //查询条件
- string starttime = txtStartTime.Text.Trim();
- string endtime = txtEndTime.Text.Trim();
- string type = hidType.Value.Trim().Replace(';', ',');
- string level = hidLevel.Value.Trim().Replace(';', ',');
- if (string.IsNullOrWhiteSpace(starttime)) { starttime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToString("yyyy-MM-dd"); txtStartTime.Text = starttime; }
- if (string.IsNullOrWhiteSpace(endtime)) { endtime = DateTime.Today.ToString("yyyy-MM-dd"); txtEndTime.Text = endtime; }
- string tabletitle = "工单流程执行效率";
- string[] tablehead = { "日期", "工单总量", "工单总用时(小时)", "工单平均用时(小时)", "指派总用时(小时)", "指派平均用时(小时)", "接单总用时(小时)", "接单平均用时(小时)", "处理总用时(小时)", "处理平均用时(小时)", "回访总用时(小时)", "回访平均用时(小时)", "结单总用时(小时)", "结单平均用时(小时)" };
- TableHtml = createTable(tabletitle, tablehead, starttime, endtime, type, level);
- }
- private string createTable(string title, string[] head, string starttime, string endtime, string type, string level)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append(createTableTitle(title));
- sb.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align='center'>");
- sb.Append(createTableHead(head));
- sb.Append(createTableBody(starttime, endtime, type, level));
- sb.Append("</table>");
- return sb.ToString();
- }
- private string createTableBody(string starttime, string endtime, string type, string level)
- {
- //收集数据
- List<List<string>> body = new List<List<string>>();
- for (DateTime dt = Convert.ToDateTime(starttime); dt <= Convert.ToDateTime(endtime); dt = dt.AddDays(1))
- {
- List<string> bodyiteam = new List<string>();
- bodyiteam.Add(dt.ToShortDateString());
- string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", 16);
- if (type != "")
- sql += " AND F_WORKORDERLEVELID in (" + type + ")";
- if (level != "")
- sql += " AND F_REPAIRLEVEL in (" + level + ")";
- sql += " AND F_STARTTIME>='" + dt.ToShortDateString() + " 00:00:00'";
- sql += " AND F_STARTTIME<='" + dt.ToShortDateString() + " 23:59:59'";
- sql += " AND F_ENDTIME IS NOT NULL AND F_ENDTIME !=''";
- DataTable dtable = new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0];
- //今天的总工单量
- int todaycount = dtable.Rows.Count;
- bodyiteam.Add(todaycount.ToString());
- //今天的工单总用时
- double todayalltime = 0.00;
- TimeSpan tstotal = new TimeSpan();
- for (int i = 0; i < dtable.Rows.Count; i++)
- {
- DateTime dtstart = new DateTime();
- DateTime dtend = new DateTime();
- if (DateTime.TryParse(dtable.Rows[i]["F_ENDTIME"].ToString(), out dtend) && DateTime.TryParse(dtable.Rows[i]["F_STARTTIME"].ToString(), out dtstart))
- {
- TimeSpan ts = (TimeSpan)(dtend - dtstart);
- tstotal += ts;
- }
- }
- todayalltime = tstotal.TotalSeconds;
- bodyiteam.Add(todayalltime.ToString("0.00"));
- //今天的平均用时
- double todaypercent = 0.00;
- if (todayalltime > 0) todaypercent = todayalltime / todaycount;
- bodyiteam.Add(todaypercent.ToString("0.00"));
- //今天的工单每个状态的总用时
- int[] state = new int[] { 4, 6, 7, 8, 9 };
- for (int j = 0; j < state.Length; j++)
- {
- double l = 0.00;
- double p = 0.00;
- for (int i = 0; i < dtable.Rows.Count; i++)
- {
- string sqlwhere = string.Format("SELECT SUM([F_ELAPSEDTIME]) FROM [T_Wo_WorkOrderHistory] WHERE [F_WORKORDERSTATEID]='{0}' AND [F_INSTANCEID]='{1}'", state[j], dtable.Rows[i]["F_INSTANCEID"].ToString());
- DataTable dtb = DBUtility.DbHelperSQL.Query(sqlwhere).Tables[0];
- double m = 0.00;
- double.TryParse(dtb.Rows[0][0].ToString(), out m);
- l += m;
- }
- if (todaycount > 0) p = l / todaycount;
- bodyiteam.Add(l.ToString("0.00"));
- bodyiteam.Add(p.ToString("0.00"));
- }
- dtable.Dispose();
- for (int item =0;item< bodyiteam.Count;item++)
- {
- if (item == 0 || item == 1) continue;
- else bodyiteam[item] = GetTimeInfo(bodyiteam[item]);
- }
- body.Add(bodyiteam);
- }
- //打印表格
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < body.Count;i++ )
- {
- if (body[i][1] != "0")
- {
- sb.Append("<tr style=\"text-align: center;\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\">");
- foreach (var listiteam in body[i])
- {
- sb.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #fff;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + listiteam + "</td>");
- }
- sb.Append("</tr>");
- }
- }
- //合计数据
- List<string> sum = new List<string>();
- sum = getSumCountAndAverage(starttime, endtime, 16, type, level);
- sb.Append("<tr style=\"text-align: center;\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\">");
- for (int j = 0; j < sum.Count; j++)
- {
- sb.Append("<td class=\"formtabletitle1\" style=\"height: 25px;background-color: #D5EDFE;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + sum[j] + "</td>");
- }
- sb.Append("</tr>");
- return sb.ToString();
- }
- private List<string> getSumCountAndAverage(string starttime, string endtime, int type, string bxtype, string bxlevel)
- {
- List<string> sum = new List<string>();
- sum.Add("合计:");
- string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", type);
- if (starttime != "")
- {
- sql += " AND F_STARTTIME>='" + starttime + " 00:00:00'";
- }
- if (endtime != "")
- {
- sql += " AND F_ENDTIME<='" + endtime + " 23:59:59'";
- }
- if (bxtype != "")
- sql += " AND F_WORKORDERLEVELID in (" + bxtype + ")";
- if (bxlevel != "")
- sql += " AND F_REPAIRLEVEL in (" + bxlevel + ")";
- DataTable dtable = new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0];
- //工单总数
- int allcount = dtable.Rows.Count;
- sum.Add(allcount.ToString());
- //工单总用时
- double alltime = 0.00;
- TimeSpan tstotal = new TimeSpan();
- for (int i = 0; i < dtable.Rows.Count; i++)
- {
- DateTime dtstart = new DateTime();
- DateTime dtend = new DateTime();
- if (DateTime.TryParse(dtable.Rows[i]["F_ENDTIME"].ToString(), out dtend) && DateTime.TryParse(dtable.Rows[i]["F_STARTTIME"].ToString(), out dtstart))
- {
- TimeSpan ts = (TimeSpan)(dtend - dtstart);
- tstotal += ts;
- }
- }
- alltime = tstotal.TotalSeconds;
- sum.Add(alltime.ToString("0.00"));
- //平均用时
- double average = 0.00;
- if (alltime > 0) average = alltime / allcount;
- sum.Add(average.ToString("0.00"));
- //工单每个状态的总用时及平均用时
- int[] state = new int[] { 4, 6, 7, 8, 9 };
- for (int j = 0; j < state.Length; j++)
- {
- double l = 0.00;
- double p = 0.00;
- for (int i = 0; i < dtable.Rows.Count; i++)
- {
- string sqlwhere = string.Format("SELECT SUM([F_ELAPSEDTIME]) FROM [T_Wo_WorkOrderHistory] WHERE [F_WORKORDERSTATEID]='{0}' AND [F_INSTANCEID]='{1}'", state[j], dtable.Rows[i]["F_INSTANCEID"].ToString());
- DataTable dtb = DBUtility.DbHelperSQL.Query(sqlwhere).Tables[0];
- double m = 0.00;
- double.TryParse(dtb.Rows[0][0].ToString(), out m);
- l += m;
- }
- if (allcount > 0) p = l / allcount;
- sum.Add(l.ToString("0.00"));
- sum.Add(p.ToString("0.00"));
- }
- dtable.Dispose();
- for (int item = 0; item < sum.Count; item++)
- {
- if (item == 0 || item == 1) continue;
- else sum[item] = GetTimeInfo(sum[item]);
- }
- return sum;
- }
- private string createTableHead(string[] head)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("<tr style=\"text-align: center;\">");
- for (int i = 0; i < head.Length; i++)
- {
- sb.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #D5EDFE;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + head[i] + "</td>");
- }
- sb.Append("</tr>");
- return sb.ToString();
- }
- protected void btnConfirm_Click(object sender, EventArgs e)
- {
- //PrintTable();
- OutputTable();
- }
- private void PrintTable()
- {
- string starttime = txtStartTime.Text.Trim();
- if (string.IsNullOrWhiteSpace(starttime)) starttime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToShortDateString();
- string endtime = txtEndTime.Text.Trim();
- if (string.IsNullOrWhiteSpace(endtime)) endtime = DateTime.Today.AddDays(-1).ToShortDateString();
- int workordercount = getWorkOrderCount(starttime, endtime, 16);
- double workorderalltime = getWorkOrderAllTime(starttime, endtime, 16);
- int averagetime = 0;
- if (workordercount > 0)
- {
- averagetime = (int)(workorderalltime / workordercount);
- }
- TableTitle = createTableTitle("工单流程执行效率");
- string[] Head1 = new string[] { "统计项", "统计结果" };
- string[,] Body1 = new string[,] { { "工单总数",workordercount.ToString()},
- { "工单总用时",GetTimeInfo(workorderalltime.ToString())},
- {"工单平均用时",GetTimeInfo(averagetime.ToString())} };
- TableOne = createTable(Head1, Body1);
- string[] Head2 = new string[] { "", "指派", "接单", "处理", "回访", "结单" };
- string[,] Body2 = new string[,] { { "总用时", "", "", "", "", "" },
- { "平均用时", "", "", "", "", "" } };
- long time4 = getOneStateTime(starttime, endtime, 16, 4);
- long time6 = getOneStateTime(starttime, endtime, 16, 6);
- long time7 = getOneStateTime(starttime, endtime, 16, 7);
- long time8 = getOneStateTime(starttime, endtime, 16, 8);
- long time9 = getOneStateTime(starttime, endtime, 16, 9);
- Body2[0, 1] = GetTimeInfo(time4.ToString());
- Body2[0, 2] = GetTimeInfo(time6.ToString());
- Body2[0, 3] = GetTimeInfo(time7.ToString());
- Body2[0, 4] = GetTimeInfo(time8.ToString());
- Body2[0, 5] = GetTimeInfo(time9.ToString());
- if (workordercount > 0)
- {
- Body2[1, 1] = GetTimeInfo((time4 / workordercount).ToString());
- Body2[1, 2] = GetTimeInfo((time6 / workordercount).ToString());
- Body2[1, 3] = GetTimeInfo((time7 / workordercount).ToString());
- Body2[1, 4] = GetTimeInfo((time8 / workordercount).ToString());
- Body2[1, 5] = GetTimeInfo((time9 / workordercount).ToString());
- }
- TableTwo = createTable(Head2, Body2);
- }
- /// <summary>
- /// 工单总数量
- /// </summary>
- /// <returns></returns>
- private int getWorkOrderCount(string starttime, string endtime, int type)
- {
- string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", type);
- if (starttime != "")
- {
- sql += " AND F_STARTTIME>='" + starttime + " 00:00:00'";
- }
- if (endtime != "")
- {
- sql += " AND F_ENDTIME<='" + endtime + " 23:59:59'";
- }
- return new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0].Rows.Count;
- }
- /// <summary>
- /// 工单总用时
- /// </summary>
- /// <returns></returns>
- private double getWorkOrderAllTime(string starttime, string endtime, int type)
- {
- string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", type);
- if (starttime != "")
- {
- sql += " AND F_STARTTIME>='" + starttime + " 00:00:00'";
- }
- if (endtime != "")
- {
- sql += " AND F_ENDTIME<='" + endtime + " 23:59:59'";
- }
- DataTable dtlist = new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0];
- TimeSpan tstotal = new TimeSpan();
- for (int i = 0; i < dtlist.Rows.Count; i++)
- {
- DateTime dtstart = new DateTime();
- DateTime dtend = new DateTime();
- if (DateTime.TryParse(dtlist.Rows[i]["F_ENDTIME"].ToString(), out dtend) && DateTime.TryParse(dtlist.Rows[i]["F_STARTTIME"].ToString(), out dtstart))
- {
- TimeSpan ts = (TimeSpan)(dtend - dtstart);
- tstotal += ts;
- }
- }
- return tstotal.TotalSeconds;
- }
- /// <summary>
- /// 某种状态的总时间
- /// </summary>
- /// <param name="state">
- /// 工单状态:
- /// 12 开始
- /// 4 待指派
- /// 6 待接单
- /// 7 待处理
- /// 8 待回访
- /// 9 待结单
- /// 0 结束
- /// </param>
- /// <returns></returns>
- private long getOneStateTime(string starttime, string endtime, int type, int state)
- {
- string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", type);
- if (starttime != "")
- {
- sql += " AND F_STARTTIME>='" + starttime + " 00:00:00'";
- }
- if (endtime != "")
- {
- sql += " AND F_ENDTIME<='" + endtime + " 23:59:59'";
- }
- DataTable dtlist = new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0];
- long l = 0;
- for (int i = 0; i < dtlist.Rows.Count; i++)
- {
- string sqlwhere = string.Format("SELECT SUM([F_ELAPSEDTIME]) FROM [T_Wo_WorkOrderHistory] WHERE [F_WORKORDERSTATEID]='{0}' AND [F_INSTANCEID]='{1}'", state, dtlist.Rows[i]["F_INSTANCEID"].ToString());
- DataTable dt = DBUtility.DbHelperSQL.Query(sqlwhere).Tables[0];
- long m = 0;
- long.TryParse(dt.Rows[0][0].ToString(), out m);
- l += m;
- }
- return l;
- }
- /// <summary>
- /// 获取不同类型,不同状态的工单数量
- /// </summary>
- /// <param name="type">工单类型:6.咨询 3.投诉 16.报修</param>
- /// <param name="state">
- /// 工单状态:
- /// 12 开始
- /// 4 待指派
- /// 6 待接单
- /// 7 待处理
- /// 8 待回访
- /// 9 待结单
- /// 0 结束
- /// </param>
- /// <returns>工单数量</returns>
- private int getWorkOrderStateCount(int type, int state)
- {
- string sqlwhere = string.Format("F_WORKORDERTYPEID='{0}' and F_WORKORDERSTATEID='{1}'", type, state);
- return new BLL.T_Wo_WorkOrderBase().GetList(sqlwhere).Tables[0].Rows.Count;
- }
- /// <summary>
- /// 时间转换(将秒转换为易读的时间)
- /// </summary>
- /// <param name="times">秒</param>
- /// <returns></returns>
- public string GetTimeInfo1(string times)
- {
- string res = "";
- try
- {
- double d = Convert.ToDouble(times);
- int t = Convert.ToInt32(d);
- if (t < 60)
- {
- res = "" + t + "秒";
- }
- else if (t < 3600)
- {
- res = "" + Convert.ToInt32(t / 60).ToString() + "分" + "" + Convert.ToInt32(t % 60).ToString() + "秒";
- }
- else if (t < 86400)
- {
- res = "" + Convert.ToInt32(t / 3600).ToString() + "时" + "" + Convert.ToInt32((t % 3600) / 60).ToString() + "分" + "" + Convert.ToInt32((t % 3600) % 60).ToString() + "秒";
- }
- else
- {
- res = "" + Convert.ToInt32(t / 86400).ToString() + "天" + "" + Convert.ToInt32((t % 86400) / 3600).ToString() + "时" + "" + Convert.ToInt32(((t % 86400) % 3600) / 60).ToString() + "分" + "" + Convert.ToInt32(((t % 86400) % 3600) % 60).ToString() + "秒";
- }
- }
- catch
- { }
- return res;
- }
- /// <summary>
- /// 把秒转化成小时
- /// </summary>
- /// <param name="times">秒</param>
- /// <returns></returns>
- public string GetTimeInfo(string times)
- {
- string res = "";
- try
- {
- double d = Convert.ToDouble(times);
- res = (d / 3600).ToString("0.00");
- }
- catch
- { }
- return res;
- }
- /// <summary>
- /// 表名称
- /// </summary>
- /// <param name="title">表名</param>
- /// <returns></returns>
- protected string createTableTitle(string title)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("<h1 style='font-size: 18px; font-weight: bold; color: #333333; text-align: center;width: 100%;'><b>" + title + "</b></h1>");
- return sb.ToString();
- }
- /// <summary>
- /// 表头(表列名)
- /// </summary>
- /// <param name="head">列名数组</param>
- /// <returns></returns>
- protected string createTable(string[] head, string[,] body)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("<table border='0' cellpadding='0' cellspacing='0' width='100%' align='center'>");
- sb.Append("<tr class=\"formtabletitle1\" style=\"height: 25px;background-color: #D5EDFE;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">");
- for (int i = 0; i < head.Length; i++)
- {
- sb.Append("<td class=\"formtabletitle1\" style=\"height: 25px;background-color: #D5EDFE;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + head[i] + "</td>");
- }
- sb.Append("</tr>");
- sb.Append(createTableBody(body));
- sb.Append("</table>");
- return sb.ToString();
- }
- private string createTableBody(string[,] body)
- {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < body.GetLength(0); i++)
- {
- sb.Append("<tr style=\"text-align: center;\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\">");
- for (int j = 0; j < body.GetLength(1); j++)
- {
- sb.Append("<td class=\"formtabletitle1\" style=\"height: 25px;background-color: #fff;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + body[i, j] + "</td>");
- }
- sb.Append("</tr>");
- }
- return sb.ToString();
- }
- protected string createTable1(string[] head, string[,] body,string[] sumiteam)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("<table border='0' cellpadding='0' cellspacing='0' width='100%' align='center'>");
- sb.Append("<tr class=\"formtabletitle1\" style=\"height: 25px;background-color: #D5EDFE;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">");
- for (int i = 0; i < head.Length; i++)
- {
- sb.Append("<td class=\"formtabletitle1\" style=\"height: 25px;background-color: #D5EDFE;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + head[i] + "</td>");
- }
- sb.Append("</tr>");
- sb.Append(createTableBody1(body));
- sb.Append("<tr class=\"formtabletitle1\" style=\"height: 25px;background-color: #E4D354;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">");
- for (int i = 0; i < sumiteam.Length; i++)
- {
- sb.Append("<td class=\"formtabletitle1\" style=\"height: 25px;background-color: #E4D354;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + sumiteam[i] + "</td>");
- }
- sb.Append("</table>");
- return sb.ToString();
- }
- private string createTableBody1(string[,] body)
- {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < body.GetLength(0); i++)
- {
- sb.Append("<tr style=\"text-align: center;\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\">");
- for (int j = 0; j < body.GetLength(1); j++)
- {
- sb.Append("<td class=\"formtabletitle1\" style=\"height: 25px;background-color: #fff;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + body[i, j] + "</td>");
- }
- sb.Append("</tr>");
- }
- return sb.ToString();
- }
- protected void btnExport_Click(object sender, EventArgs e)
- {
- string fileName = "工单流程执行效率报表" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
- Response.Clear();
- Response.Charset = "GB2312";
- Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
- Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName));
- Response.ContentType = "application/ms-excel";
- Response.Write(TableHtml);
- Response.End();
- }
- }
- }
|