C# .net mvc 实战项目生成数据表格+动态绑定数据 (七)

8 篇文章 4 订阅

效果图:
在这里插入图片描述
表格的样式经过了优化。

视图代码:


@{
    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();
        }

就是这么强大,烦恼!

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yangzm996

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值