隐患整改单导出乱码修改
This commit is contained in:
parent
8040225358
commit
a4fa48a195
|
|
@ -7,6 +7,7 @@ using System.Data.SqlClient;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AspNet = System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.HSSE.Check
|
||||
{
|
||||
|
|
@ -342,6 +343,59 @@ namespace FineUIPro.Web.HSSE.Check
|
|||
Response.Write(GetGridTableHtml(Grid1));
|
||||
Response.End();
|
||||
}
|
||||
public static string GetGridTableHtml(Grid grid)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||||
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
||||
sb.Append("<tr>");
|
||||
|
||||
foreach (GridColumn column in grid.Columns)
|
||||
{
|
||||
if (column.ColumnID != "Actions" && !column.Hidden)
|
||||
{
|
||||
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||||
}
|
||||
}
|
||||
sb.Append("</tr>");
|
||||
foreach (GridRow row in grid.Rows)
|
||||
{
|
||||
sb.Append("<tr>");
|
||||
foreach (GridColumn column in grid.Columns)
|
||||
{
|
||||
if (column.ColumnID != "Actions" && !column.Hidden)
|
||||
{
|
||||
string html = row.Values[column.ColumnIndex].ToString();
|
||||
if (column.ColumnID == "tfNumber" && (row.FindControl("labNumber") as AspNet.Label) != null)
|
||||
{
|
||||
html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
||||
}
|
||||
if (column.ColumnID == "CheckManNames" && (row.FindControl("Label2") as AspNet.Label) != null)
|
||||
{
|
||||
html = (row.FindControl("Label2") as AspNet.Label).Text;
|
||||
}
|
||||
// 处理CheckBox
|
||||
if (html.Contains("f-grid-static-checkbox"))
|
||||
{
|
||||
if (!html.Contains("f-checked"))
|
||||
{
|
||||
html = "×";
|
||||
}
|
||||
else
|
||||
{
|
||||
html = "√";
|
||||
}
|
||||
}
|
||||
sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html);
|
||||
// sb.AppendFormat("<td>{0}</td>", html);
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append("</tr>");
|
||||
}
|
||||
sb.Append("</table>");
|
||||
return sb.ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected void rbStates_SelectedIndexChanged(object sender, EventArgs e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue