从KendoUI编辑器自定义导出到单词保存到数据库的屏幕快照不会导出到单词

时间:2019-05-02 10:31:19

标签: c# kendo-ui ms-word kendo-asp.net-mvc export-to-word

你好,我有一个疑问,例如我正在使用剑道UI编辑器 https://demos.telerik.com/aspnet-mvc/editor/import-export,并将该UI编辑器的内容(如屏幕截图,文本输入的数据等)的详细信息保存到DB,同时检索并显示在UI中,我可以通过解码来显示。但是我有需求,例如需要导出到Word。.当我想将内容从DB导出到Word时,再次对其进行解码并导出,但是屏幕截图没有导出到Word。请帮忙寻找解决方法

代码如下:

  public void ExporttoHtml(int no)
    {

        HttpContext.Response.Clear();
        HttpContext.Response.Charset = "";

        #region HtmlDesign
        System.Web.HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
        Response.ContentEncoding = Encoding.Default;
        HttpContext.Response.ContentType = "application/msword";
        Response.AddHeader("content-disposition", "attachment; filename=" + no + ".doc");
        StringBuilder bodycontent = new StringBuilder("");
        GetContentToExporttoWord(bodycontent, no);
        #endregion



        #region Rendering 
        HttpContext.Response.Write(bodycontent);
        HttpContext.Response.End();
        HttpContext.Response.Flush();
        #endregion
    }
    private void GetContentToExporttoWord(StringBuilder bodycontent, int no)
    {
        Exportdetail objecdet = GetDetailsfromDB(no);

        bodycontent.Append(@"<html 
                            xmlns:o='urn:schemas-microsoft-com:office:office' 
                            xmlns:w='urn:schemas-microsoft-com:office:word'
                            xmlns='http://www.w3.org/TR/REC-html40'>
                            <head><title></title>



                         </head>
       <body lang=EN-US style='tab-interval:.5in'>");
        bodycontent.Append("<h2><table valign = 'middle' width = '100%' Border = '0' Cellpadding = '2' Cellspacing = '2'><tr>");
        bodycontent.Append("<div class='Section1'>");
        bodycontent.Append("<table valign = 'middle' width = '100% ' Border = '0' Cellpadding = '2' Cellspacing = '2' class='page-break-after:always'>");

        bodycontent.Append("<td colspan='2'><b><span style=' width:100px;'>Request Description:&nbsp;&nbsp;</span></b> " + HttpUtility.HtmlDecode(objecdet.EditorData + "</td></tr></div>"));
    }

    public class Exportdetail
    {
        public string EditorData { get; set; }

    }
}

0 个答案:

没有答案