如何在asp.net C#MVC中将HTML导出为ms word .doc格式?我一直在尝试,但我无法完成它。有没有正确的方法来完成它?没有扰乱表等的布局?我很多天都在寻找和尝试,但不能。有什么帮助吗?
代码:
<pre lang="HTML">@if (@Item == null)
{
<p style="Font-Size:large; color:Red">No Record Found for this User in <span><i>'@ViewBag.Month'</i></span> </p>
}
else
{
<div class='continer'>
<div class = 'header'>
<div class="emp_inf">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<th class="title" colspan="2">PRECISE TECHNOLOGY</th>
<th class="slip_type" colspan="2">Official Copy</th>
<th colspan="2"><img src="@Url.Content("~/Content/csm_logo.png")" class ='titleimg' alt="No Image"></img></th>
</tr>
<tr>
<td class="midtext" colspan="6">
<span class='payslip'>Pay Slip for the month of <b>@Item.Month</b> </span> <br />
<span>Voucher No.   @Item.EmplID/@System.DateTime.Now.Month/@System.DateTime.Now.Year.ToString().Substring(2, 2)</span>
</td>
</tr>
<tr>
<td>
Name
</td>
<td colspan="2">
@Item.EmplName
</td>
<td>
Designation
</td>
<td colspan="2">
@Item.DeptName
</td>
</tr>
<tr>
<td>Hours Worked</td>
<td colspan="2">@Item.OverallTime</td>
<td>Basic Salary PKR</td>
<td colspan="2">@Item.NetSalary</td>
</tr>
<tr style="border-bottom:solid 3px black">
<td>Required Hours</td>
<td colspan="2">@Item.ReqHours</td>
<td>Payment Date</td>
<td colspan="2">@System.DateTime.Now.ToShortDateString()</td>
</tr>
<tr>
<td colspan="3" class="td_text_Align">Earning(s)</td>
<td colspan="3" class="td_text_Align">Deduction(s)</td>
</tr>
<tr>
@*Earnings Section*@
<th>Description</th>
<th>Pay/Hr</th>
<th>Amount PKR</th>
@*Deductions Section*@
<th>Description</th>
<th>Pay/Hr</th>
<th>Amount PKR</th>
</tr>
<tr>
@*Earnings Section*@
<td class="td_height td_vertical_align" width="20%">
Hours Worked: @Item.OverallTime  
<br />
<br />
Overtime:  @Item.OverTime
</td>
<td class="td_height td_vertical_align" width="15%">@Item.PayPerHr
<br />
<br />
@Item.OvertimeCal
</td>
<td class="td_height td_vertical_align" width="15%">@Item.TotalSalary
<br />
<br />
@Item.OverTimeTotalPay</td>
@*Deductions Section*@
<td width="20%"></td>
<td width="15%"></td>
<td width="15%"></td>
</tr>
<tr>
<td class="td_text_Align">Total Earning(s)</td>
<td></td>
@if(Convert.ToBoolean( @Item.IsAppr == true))
{
<td>PKR= @Item.SalaryOvertimeTotal</td>
}
else
{
<td>PKR= @Item.TotalSalary </td>
}
<td class="td_text_Align">Deduction(s) </td>
<td></td>
<td>PKR=</td>
</tr>
<tr></tr>
</table>
<br />
<table class="element_borderless">
<tr >
<td class="element_borderless"><b>HR Manager</b></td>
<td class="element_borderless">_________________</td>
<td class="element_borderless">Net Paymnet PKR</td>
<td class="element_borderless">
@if (@Item.TotalSalary >