2023-10-30
This commit is contained in:
+68
-8
@@ -593,7 +593,7 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
{
|
||||
Response.ClearContent();
|
||||
string filename = Funs.GetNewFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("合同执行跟踪表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("进度检测表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
Response.ContentType = "application/excel";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
this.Grid1.PageSize = 500;
|
||||
@@ -607,27 +607,87 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
/// <returns></returns>
|
||||
//private 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)
|
||||
// {
|
||||
// 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)
|
||||
// {
|
||||
// string html = row.Values[column.ColumnIndex].ToString();
|
||||
// if (column.ColumnID == "tfNumber")
|
||||
// {
|
||||
// html = (row.FindControl("lblNumber") as System.Web.UI.WebControls.Label).Text;
|
||||
// }
|
||||
// sb.AppendFormat("<td>{0}</td>", html);
|
||||
// }
|
||||
|
||||
// sb.Append("</tr>");
|
||||
// }
|
||||
|
||||
// sb.Append("</table>");
|
||||
|
||||
// return sb.ToString();
|
||||
//}
|
||||
private string GetGridTableHtml(Grid grid)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||||
|
||||
MultiHeaderTable mht = new MultiHeaderTable();
|
||||
mht.ResolveMultiHeaderTable(Grid1.Columns);
|
||||
|
||||
|
||||
sb.Append("<meta http-equiv=\"Content-Type\" content=\"application/vnd.ms-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)
|
||||
|
||||
foreach (List<object[]> rows in mht.MultiTable)
|
||||
{
|
||||
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||||
sb.Append("<tr>");
|
||||
foreach (object[] cell in rows)
|
||||
{
|
||||
int rowspan = Convert.ToInt32(cell[0]);
|
||||
int colspan = Convert.ToInt32(cell[1]);
|
||||
GridColumn column = cell[2] as GridColumn;
|
||||
|
||||
sb.AppendFormat("<th{0}{1}{2}>{3}</th>",
|
||||
rowspan != 1 ? " rowspan=\"" + rowspan + "\"" : "",
|
||||
colspan != 1 ? " colspan=\"" + colspan + "\"" : "",
|
||||
colspan != 1 ? " style=\"text-align:center;\"" : "",
|
||||
column.HeaderText);
|
||||
}
|
||||
sb.Append("</tr>");
|
||||
}
|
||||
sb.Append("</tr>");
|
||||
|
||||
|
||||
foreach (GridRow row in grid.Rows)
|
||||
{
|
||||
sb.Append("<tr>");
|
||||
foreach (GridColumn column in grid.Columns)
|
||||
|
||||
foreach (GridColumn column in mht.Columns)
|
||||
{
|
||||
string html = row.Values[column.ColumnIndex].ToString();
|
||||
|
||||
if (column.ColumnID == "tfNumber")
|
||||
{
|
||||
html = (row.FindControl("lblNumber") as System.Web.UI.WebControls.Label).Text;
|
||||
}
|
||||
else if (column.ColumnID == "tfGender")
|
||||
{
|
||||
html = (row.FindControl("labGender") as System.Web.UI.WebControls.Label).Text;
|
||||
}
|
||||
|
||||
|
||||
sb.AppendFormat("<td>{0}</td>", html);
|
||||
}
|
||||
|
||||
@@ -641,6 +701,6 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user