1:传递 List<实体类>
前端页面
@using AX.MES.Entity.ReportCenter; //引入实体类
@{
ViewBag.Title = "WIPReportExcel";
var list = ViewBag.list as List<WIPReportDTO>;//接收后台返回的值
}
<style>
.tab, .tab tr th, .tab tr td {
border: 1px solid #eee;
line-height: 25px;
font-size: 14px;
}
.tab tr {
height: 35px;
}
</style>
<h2>WIPReportExcel</h2>
<table class="tab" style="width:100%">
<thead>
<tr>
<th>日期</th>
<th>生产管理员</th>
<th>JOB</th>
<th>PN</th>
<th>数量</th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < list.Count; i++)
{
var item = list[i];
<tr>
<td>@item.ReportDate</td>
<td>Z20</td>
<td>@item.JOB</td>
<td>@item.OUT_QTY</td>
<td>@item.HeaderSmallPic</td>
<td>@(item.OUT_QTY * item.HeaderSmallPic)</td>
//可以做运算
</tr>
}
</tbody>
</table>
后端 view 控制器
public ActionResult WIPReportExcel()
{
var list = bll.GetAllWIPReportList("", "");
ViewBag.list = list;
return View();
}