将Html导出到Word [英] Export Html to Word

查看:738
本文介绍了将Html导出到Word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将html导出为word,为此我将telerik RadEditor控件作为html控件。我正在使用Syncfusion进行导出过程并且其工作正常但是当我导出图像时它不显示在word文件中我使用下面的代码来解释这可以帮助我解决这个问题。



I want to export html to word and for this I am telerik RadEditor control as html control. I am doing exporting process using Syncfusion and its work fine but when i export image it not display in word file i am using below code fot this can any one help me to solve this.

string errorMessage = "";

        IWParagraph para;
        WordDocument document = new WordDocument();
        IWSection section;
        protected void Export_Click(object sender, EventArgs e)
        {
            section = document.AddSection();
            para = section.AddParagraph();
            string htmlText = txtBody.Content;
            bool valid = section.Body.IsValidXHTML(htmlText, XHTMLValidationType.Transitional, out errorMessage);
            if (!valid)
            {
                lblHtmlMessage.Text = "Content is not a well formatted XHTML content \nError message:\n" + errorMessage;
            }
            else
            {
                lblHtmlMessage.Text = "Conversion Successful";

                document.XHTMLValidateOption = XHTMLValidationType.Transitional;
                section.Body.InsertXHTML(htmlText);


                try
                {
                    document.Save("test.docx", FormatType.Word2010, Response, HttpContentDisposition.Attachment);
                }
                catch { }
            }
        }

推荐答案

使用此一个。

http://html2openxml.codeplex.com/ [ ^ ]
Use This One.
http://html2openxml.codeplex.com/[^]


这篇关于将Html导出到Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆