Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to export mvc3 razor view to excel
    primarykey
    data
    text
    <p>I am using following action to export view to mx-exel. </p> <pre><code> public ActionResult ExportIssueVoucherReport() { Response.AddHeader("Content-Type", "application/vnd.ms-excel"); var lis1 = TempData["IssueVoucher"]; return View(lis1); } </code></pre> <p>This code works fine. My view looks like this</p> <pre><code> @model FHIControl.Model.Issue.IssueDTO @{ Layout = ""; var count = 0; } &lt;style type="text/css"&gt; .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; } &lt;/style&gt; &lt;table cellspacing=0 cellpadding=0 width="900px"@* class="tblcontents"*@&gt; &lt;tr&gt; &lt;td colspan="3" align="center" &gt;&lt;b&gt;Issue Voucher&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3"&gt; &lt;table&gt; &lt;td&gt;Date:@Model.IssueDate.ToShortDateString()&lt;/td&gt; &lt;td width="400px" align="left"&gt;Issue Voucher Number:&lt;b&gt;@Model.TNo.TNoWithPre&lt;/b&gt;&lt;br /&gt; Issued To:@Model.Receiver.PartyName &lt;/td&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;strong&gt;SN&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;Quantity&lt;/strong&gt;&lt;/td&gt; &lt;/tr&gt; @foreach (var item in Model.Details) { &lt;tr&gt; &lt;td valign="top" width="30px"&gt;@{count++;}@count&lt;/td&gt; &lt;td&gt; Commodity: @Html.DisplayFor(modelItem =&gt; item.ItemName) &lt;/td&gt; &lt;td width="100px" valign="top"&gt; @Html.DisplayFor(modelitem=&gt;item.Quantity) &lt;/td&gt; &lt;/tr&gt; } &lt;tr style="border:none;"&gt; &lt;td colspan="3" style="border:none; padding:10px 0 0 0;"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;p&gt; Received By: &lt;/p&gt;&lt;p&gt; Signature:___________________________ &lt;/p&gt;&lt;p&gt; Name: ____________________________ &lt;/p&gt;&lt;p&gt; Received Date:_______________________ &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>When I export this view I get messed up cells in excels all design is messed up.</p> <p>I am confused why style/css is not working.I have searched all over but cant find exact answer.Is there any way to fix this problem??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload