Hi @Customer Support ,
the HTML formatting is getting messed up.
How do you now? I tested @azzedinehtmlsql .Raw(message). And then I try to export html to the word and I success. What's your problem?
<div id="Grid">
@Html.Raw(message)
</div>
@using (Html.BeginForm("Export", "Home", FormMethod.Post))
{
<input type="hidden" name="GridHtml" />
<input type="submit" id="btnSubmit" value="Export" />
}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("#btnSubmit").click(function () {
$("input[name='GridHtml']").val($("#Grid").text());
});
});
</script>
[HttpPost]
[ValidateInput(false)]
public EmptyResult Export(string GridHtml)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=Grid.doc");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-word";
Response.Output.Write(GridHtml);
Response.Flush();
Response.End();
return new EmptyResult();
}
Best regards,
Yijing Sun
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.