效果图:
表格的样式经过了优化。
视图代码:
@{
ViewBag.Title = "MReport";
}
<style>
table {
width: 100%;
table-layout: fixed;
border-collapse: collapse;
}
tr td, th {
border: 1px solid black;
text-align: center;
}
.mt {
}
.title {
width: 200px;
text-align: center;
height: 50px;
}
.font_div {
font-weight: bold; /*加粗*/
text-align: center; /* 水平居中 */
}
</style>
<body>
<p class="font_div" style="margin-top:50px">数据报表 </p>
<p class="font_div">名称:@Session["name"]</p>
<table>
<colgroup>
<col class="title">
<col width="auto">
<col class="title">
<col width="auto">
</colgroup>
<tr class="title">
<th rowspan="2">
面积(cm²)
</th>
<th rowspan="2" colspan="2">
@Session["S0"]
</th>
<th rowspan="2">
压力
</th>
<th>
设计
</th>
<th>
@Session["S1"]
</th>
</tr>
<tr class="title">
<th>
实际
</th>
<th>
@Session["S2"]
</th>
</tr>
<tr class="title">
<th colspan="4">
时间
</th>
<th colspan="2">
行程
</th>
</tr>
<tr class="title">
<th>
开时间(s)
</th>
<th>
时间(s)
</th>
<th>
关时间(s)
</th>
<th>
时间(s)
</th>
<th>
设计(mm)
</th>
<th>
实际(mm)
</th>
</tr>
<tr class="title">
<th>
@Session["S3"]
</th>
<th>
@Session["S4"]
</th>
<th>
@Session["S5"]
</th>
<th>
@Session["S6"]
</th>
<th>
@Session["S7"]
</th>
<th>
@Session["S8"]
</th>
</tr>
<tr class="title">
<th colspan="6">
紧力
</th>
</tr>
<tr class="title">
<th>
压力设计(kPa)
</th>
<th>
压力实际(kPa)
</th>
<th>
关紧力(kN)
</th>
<th>
开紧压力(kPa)
</th>
<th>
预压紧压力(kPa)
</th>
<th>
预压紧力实际(kN)
</th>
</tr>
<tr class="title">
<th>
@Session["S9"]
</th>
<th>
@Session["S10"]
</th>
<th>
@Session["S11"]
</th>
<th>
@Session["S12"]
</th>
<th>
@Session["S13"]
</th>
<th>
@Session["S14"]
</th>
</tr>
<tr class="title">
<th>
摩擦力(kN)
</th>
<th>
@Session["S15"]
</th>
<th>
行程(%)
</th>
<th>
@Session["S16"]
</th>
<th>
平均摩擦力(kN)
</th>
<th>
@Session["S17"]
</th>
</tr>
<tr class="title">
<th colspan="6">
动作/复位
</th>
</tr>
<tr class="title">
<th colspan="2">
编号
</th>
<th>
S1
</th>
<th>
S2
</th>
<th>
S3
</th>
<th>
S4
</th>
</tr>
<tr class="title">
<th colspan="2">
动作
</th>
<th>
@Session["S18"]
</th>
<th>
@Session["S19"]
</th>
<th>
@Session["S20"]
</th>
<th>
@Session["S21"]
</th>
</tr>
<tr class="title">
<th colspan="2">
复位
</th>
<th>
@Session["S22"]
</th>
<th>
@Session["S23"]
</th>
<th>
@Session["S24"]
</th>
<th>
@Session["S25"]
</th>
</tr>
</table>
</body>
控制器代码:
public ActionResult MReport()
{
Session["name"] = "测试";
List<string> TestReport = new List<string>();
for (int i = 0; i < 26; i++)
{
string name = "S" + i;
TestReport.Add(name);
Session[name] = i + 1;
}
return View();
}
就是这么强大,烦恼!