安全危害因素(第一版)
This commit is contained in:
@@ -995,11 +995,11 @@ namespace FineUIPro.Web
|
||||
{
|
||||
if (!html.Contains("f-checked"))
|
||||
{
|
||||
html = "×";
|
||||
html = "✘";
|
||||
}
|
||||
else
|
||||
{
|
||||
html = "√";
|
||||
html = "✔";
|
||||
}
|
||||
}
|
||||
sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html);
|
||||
@@ -1045,6 +1045,233 @@ namespace FineUIPro.Web
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 多表头导出方法
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
/// <returns></returns>
|
||||
public string GetGridMultiHeaderTableHtml(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 != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del")
|
||||
// {
|
||||
// sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||||
// }
|
||||
//}
|
||||
//sb.Append("</tr>");
|
||||
MultiHeaderTable mht = new MultiHeaderTable();
|
||||
mht.ResolveMultiHeaderTable(grid.Columns);
|
||||
|
||||
foreach (List<object[]> rows in mht.MultiTable)
|
||||
{
|
||||
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;
|
||||
if (column.Hidden == false)
|
||||
{
|
||||
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>");
|
||||
}
|
||||
foreach (GridRow row in grid.Rows)
|
||||
{
|
||||
sb.Append("<tr>");
|
||||
//if (row.Grid.gr.Hidden == false) {
|
||||
foreach (GridColumn column in mht.Columns)
|
||||
{
|
||||
if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del")
|
||||
{
|
||||
string html = row.Values[column.ColumnIndex].ToString();
|
||||
if (column.ColumnID == "tfNumber")
|
||||
{
|
||||
html = (row.FindControl("lblNumber") as AspNet.Label).Text;
|
||||
}
|
||||
else if (column.ColumnID == "tfPageIndex")
|
||||
{
|
||||
html = (row.FindControl("lblPageIndex") as AspNet.Label).Text;
|
||||
}
|
||||
else if (column.ColumnID == "tfState")
|
||||
{
|
||||
html = (row.FindControl("lbState") as AspNet.Label).Text;
|
||||
}
|
||||
// 处理CheckBox
|
||||
if (html.Contains("f-grid-static-checkbox"))
|
||||
{
|
||||
if (!html.Contains("f-checked"))
|
||||
{
|
||||
html = "✘";
|
||||
}
|
||||
else
|
||||
{
|
||||
html = "✔";
|
||||
}
|
||||
}
|
||||
|
||||
sb.AppendFormat("<td>{0}</td>", html);
|
||||
}
|
||||
}
|
||||
//}
|
||||
sb.Append("</tr>");
|
||||
}
|
||||
|
||||
sb.Append("</table>");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region 多表头处理
|
||||
|
||||
/// <summary>
|
||||
/// 处理多表头的类
|
||||
/// </summary>
|
||||
public class MultiHeaderTable
|
||||
{
|
||||
// 包含 rowspan,colspan 的多表头,方便生成 HTML 的 table 标签
|
||||
public List<List<object[]>> MultiTable = new List<List<object[]>>();
|
||||
// 最终渲染的列数组
|
||||
public List<GridColumn> Columns = new List<GridColumn>();
|
||||
|
||||
public void ResolveMultiHeaderTable(GridColumnCollection columns)
|
||||
{
|
||||
List<object[]> row = new List<object[]>();
|
||||
foreach (GridColumn column in columns)
|
||||
{
|
||||
object[] cell = new object[4];
|
||||
cell[0] = 1; // rowspan
|
||||
cell[1] = 1; // colspan
|
||||
cell[2] = column;
|
||||
cell[3] = null;
|
||||
|
||||
row.Add(cell);
|
||||
}
|
||||
|
||||
ResolveMultiTable(row, 0);
|
||||
ResolveColumns(row);
|
||||
}
|
||||
|
||||
private void ResolveColumns(List<object[]> row)
|
||||
{
|
||||
foreach (object[] cell in row)
|
||||
{
|
||||
GroupField groupField = cell[2] as GroupField;
|
||||
if (groupField != null && groupField.Columns.Count > 0)
|
||||
{
|
||||
List<object[]> subrow = new List<object[]>();
|
||||
foreach (GridColumn column in groupField.Columns)
|
||||
{
|
||||
subrow.Add(new object[]
|
||||
{
|
||||
1,
|
||||
1,
|
||||
column,
|
||||
groupField
|
||||
});
|
||||
}
|
||||
|
||||
ResolveColumns(subrow);
|
||||
}
|
||||
else
|
||||
{
|
||||
Columns.Add(cell[2] as GridColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ResolveMultiTable(List<object[]> row, int level)
|
||||
{
|
||||
List<object[]> nextrow = new List<object[]>();
|
||||
|
||||
foreach (object[] cell in row)
|
||||
{
|
||||
GroupField groupField = cell[2] as GroupField;
|
||||
if (groupField != null && groupField.Columns.Count > 0)
|
||||
{
|
||||
// 如果当前列包含子列,则更改当前列的 colspan,以及增加父列(向上递归)的colspan
|
||||
cell[1] = Convert.ToInt32(groupField.Columns.Count);
|
||||
PlusColspan(level - 1, cell[3] as GridColumn, groupField.Columns.Count - 1);
|
||||
|
||||
foreach (GridColumn column in groupField.Columns)
|
||||
{
|
||||
nextrow.Add(new object[]
|
||||
{
|
||||
1,
|
||||
1,
|
||||
column,
|
||||
groupField
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MultiTable.Add(row);
|
||||
|
||||
// 如果当前下一行,则增加上一行(向上递归)中没有子列的列的 rowspan
|
||||
if (nextrow.Count > 0)
|
||||
{
|
||||
PlusRowspan(level);
|
||||
|
||||
ResolveMultiTable(nextrow, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void PlusRowspan(int level)
|
||||
{
|
||||
if (level < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (object[] cells in MultiTable[level])
|
||||
{
|
||||
GroupField groupField = cells[2] as GroupField;
|
||||
if (groupField != null && groupField.Columns.Count > 0)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
else
|
||||
{
|
||||
cells[0] = Convert.ToInt32(cells[0]) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
PlusRowspan(level - 1);
|
||||
}
|
||||
|
||||
private void PlusColspan(int level, GridColumn parent, int plusCount)
|
||||
{
|
||||
if (level < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (object[] cells in MultiTable[level])
|
||||
{
|
||||
GridColumn column = cells[2] as GridColumn;
|
||||
if (column == parent)
|
||||
{
|
||||
cells[1] = Convert.ToInt32(cells[1]) + plusCount;
|
||||
|
||||
PlusColspan(level - 1, cells[3] as GridColumn, plusCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据身份证号码获取年龄
|
||||
|
||||
Reference in New Issue
Block a user