这种方式我个人还是比较喜欢的,使用部分视图的方式,导出Execl 这样在编辑样式上也是很方便的

 

第一步: 编辑导出视图页

 

@using H5UpdateImage.Models;
@{
    Layout = null;
    Response.AddHeader("Content-disposition", "attachment;filename=Order.xls");
}

@model List<Order>
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ExeclIndex</title>
    <style type="text/css">
        .ltable th {
            padding: 8px 0;
            color: #333;
            font-size: 12px;
            font-weight: 500;
            background: #f3f3f3;
            border-bottom: 1px solid #E1E1E1;
            line-height: 1.5em;
        }

        .ltable th, .ltable td {
            border: 1px solid #e1e1e1;
            text-align: center;
        }

        .ltable th {
            padding: 8px 0;
            color: #333;
            font-size: 12px;
            font-weight: 500;
            background: #f3f3f3;
            border-bottom: 1px solid #E1E1E1;
            line-height: 1.5em;
        }
    </style>

</head>
<body>
    <table class="ltable">
        <thead>
            <tr>
                <th> 订单编号</th>
                <th>订单来源</th>
                <th>会员姓名</th>

            </tr>
        </thead>
        <tbody class="ltbody">
            @foreach (var item in Model)
            {
                <tr>
                    <td>@item.Id</td>
                    <td>@item.Name</td>
                    <td>@item.CreateTime</td>
                </tr>
            }
        </tbody>
    </table>
</body>
</html>
View Code

相关文章:

  • 2022-12-23
  • 2021-12-23
  • 2021-04-26
  • 2021-12-26
  • 2023-03-10
  • 2021-12-18
猜你喜欢
  • 2021-06-29
  • 2021-10-20
  • 2021-11-27
  • 2022-12-23
  • 2023-02-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案