.doc文件已创建,但样式和颜色不适用于asp.net

时间:2015-05-21 08:41:43

标签: c# asp.net xmldocument

我正在创建.doc文件,但它只用字符串创建,没有设计正在应用。只是简单的字符串进入.doc文件

  System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        System.Xml.XmlDocument dom = new System.Xml.XmlDocument();
        design.RenderControl(htmlWrite);
        string strBuilder = stringWrite.ToString().Replace("&", "&");
        System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
        xmlDoc.LoadXml(strBuilder);
        string rawText = xmlDoc.InnerText;
        string strPath = Request.PhysicalApplicationPath + "\\Temp\\WeeklyReport of " + Projname + ".doc";
        var doc = DocX.Create(strPath,DocumentTypes.Document);
        doc.InsertParagraph(rawText);
        doc.Save();

0 个答案:

没有答案