我正在使用以下操作将视图导出到mx-exel。
public ActionResult ExportIssueVoucherReport()
{
Response.AddHeader("Content-Type", "application/vnd.ms-excel");
var lis1 = TempData["IssueVoucher"];
return View(lis1);
}
此代码工作正常。 我的观点看起来像这样
@model FHIControl.Model.Issue.IssueDTO
@{
Layout = "";
var count = 0;
}
<style type="text/css">
.StampBox
{
display:block;
border: 1px solid;
padding:2px 10px 2px 10px;
margin:10px 0px;
height:100px;
width:250px;
float:right;
display:inline;
}
table table td.BOXSTamp
{
width:350px;
border:1px solid black;
}
</style>
<table cellspacing=0 cellpadding=0 width="900px"@* class="tblcontents"*@>
<tr>
<td colspan="3" align="center" ><b>Issue Voucher</b></td>
</tr>
<tr>
<td colspan="3">
<table>
<td>Date:@Model.IssueDate.ToShortDateString()</td>
<td width="400px" align="left">Issue Voucher Number:<b>@Model.TNo.TNoWithPre</b><br />
Issued To:@Model.Receiver.PartyName
</td>
</table>
</td>
</tr>
<tr>
<td><strong>SN</strong></td>
<td><strong>Description</strong></td>
<td><strong>Quantity</strong></td>
</tr>
@foreach (var item in Model.Details)
{
<tr>
<td valign="top" width="30px">@{count++;}@count</td>
<td>
Commodity:
@Html.DisplayFor(modelItem => item.ItemName)
</td>
<td width="100px" valign="top">
@Html.DisplayFor(modelitem=>item.Quantity)
</td>
</tr>
}
<tr style="border:none;">
<td colspan="3" style="border:none; padding:10px 0 0 0;">
<table>
<tr>
<td><p>
Received By:
</p><p>
Signature:___________________________
</p><p>
Name: ____________________________
</p><p>
Received Date:_______________________
</tr>
</table>
</td>
</tr>
</table>
当我导出这个视图时,我在excel中搞乱了所有设计都搞砸了。
我很困惑为什么style / css不起作用。我已经搜索了所有但无法找到确切的答案。有什么方法可以解决这个问题吗?