在.net中自定义表头 switch (e.Row.RowType) { case DataControlRowType.Header: //第一行表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); //tcHeader[0].Style = "font-family:@MS Gothic"; tcHeader[0].Attributes.Add("rowspan", "3"); //跨Rowborder:1; ; //tcHeader[0].Attributes.Add("bgcolor", "white"); tcHeader[0].Text = "社区"; tcHeader[0].Style.Value = "border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Attributes.Add("colspan", "14"); //跨Column tcHeader[1].Text = "社区下所有人六大慢病统计"; tcHeader[1].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader[2].Text = "复合<br/>条件</th></tr><tr>"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("colspan", "2"); //跨Column tcHeader[3].Text = "高血压"; tcHeader[3].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader[4].Attributes.Add("colspan", "2"); tcHeader[4].Text = "冠心病"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader[5].Attributes.Add("colspan", "2"); tcHeader[5].Text = "脑卒中"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader[6].Attributes.Add("colspan", "2"); tcHeader[6].Text = "糖尿病"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader[7].Attributes.Add("colspan", "2"); tcHeader[7].Text = "肿瘤"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader[8].Attributes.Add("colspan", "2"); tcHeader[8].Text = "慢阻肺"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader[9].Attributes.Add("colspan", "2"); tcHeader[9].Text = "总计"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].Style.Value = "border: 1px solid #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;color: #1A479A;"; tcHeader[10].Attributes.Add("colspan", "1"); tcHeader[10].Text = "</th></tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[11].Text = "人数"; tcHeader[11].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[12].Text = "患病率%"; tcHeader[12].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[13].Text = "人数"; tcHeader[13].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[14].Text = "患病率%"; tcHeader[14].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[15].Text = "人数"; tcHeader[15].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[16].Text = "患病率%"; tcHeader[16].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[17].Text = "人数"; tcHeader[17].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[18].Text = "患病率%"; tcHeader[18].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[19].Text = "人数"; tcHeader[19].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[20].Text = "患病率%"; tcHeader[20].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[21].Text = "人数"; tcHeader[21].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[22].Text = "患病率%"; tcHeader[22].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; //tcHeader.Add(new TableHeaderCell()); //tcHeader[21].Text = "患病人次"; //tcHeader[21].Style.Value = "border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[23].Text = "人数"; tcHeader[23].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader.Add(new TableHeaderCell()); tcHeader[24].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader[24].Text = "患病率%"; tcHeader.Add(new TableHeaderCell()); tcHeader[25].Style.Value = "border: 1px solid #999999;border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: /"宋体/";font-size: 12px;font-weight: bold;"; tcHeader[25].Text = "人数"; //下线</tr><tr> break; }