把富文本里的html 插入word中 把富文本里的html插入到word中。各位高人,求具体的实现方式或demo,不盛感激。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public void ToWord(string html) { string htmlSaveText = "<html><head><title></title></head><body>"; htmlSaveText += html; htmlSaveText += "</body></html>"; //建立html文件 string path = System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/Export/") + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".html"; using (FileStream fs = File.Create(path)) { byte[] info = new UTF8Encoding(true).GetBytes(htmlSaveText); fs.Write(info, 0, info.Length); } //File.AppendAllText(path, htmlSaveText, Encoding.Default); object Nothing = Missing.Value; wDoc.Paragraphs.Last.Range.InsertFile(path, ref Nothing, ref Nothing, ref Nothing, ref Nothing); }现在这个方法,可以在word段落最后加上html显示的内容,怎么在指定的地方加? Document doc = new Document(Server.MapPath(tempFile)); DocumentBuilder builder = new DocumentBuilder(doc); foreach (var key in dic.Keys) { var repStr = string.Format("{0}", key); if (key == "$合同内容$") { doc.Range.Replace(repStr, "", false, false); Book book = doc.Range.Books[0]; builder.MoveToBook(book.Name); builder.InsertHtml(dic[key]); } else if (key == "$附件内容$") { doc.Range.Replace(repStr, "", false, false); Book book = doc.Range.Books[0]; builder.MoveToBook(book.Name); builder.InsertHtml(dic[key]); } else { doc.Range.Replace(repStr, dic[key], false, false); } }现在遇到个问题,二个定位到了一起。doc.Range.Books[1]肯定是错的。怎么正确分别定位 NHibernate 存储的问题。 SaveFileDialog修改难题,大家帮忙。super BT~~~~ 求一个简单的循环 DataGridView的运用 紧急求助 showModalDialog 打开页面的问题? [请教]为什么有了公共变量还要使用属性? C#DataSet.tables怎么定义XML编码以及保存注释 高分请教一问题,.net2.0操作SQL 2005数据上面的, 窗体应用程序中ListBox控件与ACCESS表的绑定问题! 票据打印页面设置问题?急急 如果把这一串字符串转为16进制的ASCII码 C# 中picturebox控件的图片如何变回来?
{ string htmlSaveText = "<html><head><title></title></head><body>";
htmlSaveText += html;
htmlSaveText += "</body></html>";
//建立html文件
string path = System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/Export/") + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".html";
using (FileStream fs = File.Create(path))
{
byte[] info = new UTF8Encoding(true).GetBytes(htmlSaveText);
fs.Write(info, 0, info.Length);
}
//File.AppendAllText(path, htmlSaveText, Encoding.Default);
object Nothing = Missing.Value;
wDoc.Paragraphs.Last.Range.InsertFile(path, ref Nothing, ref Nothing,
ref Nothing, ref Nothing);
}
现在这个方法,可以在word段落最后加上html显示的内容,怎么在指定的地方加?
DocumentBuilder builder = new DocumentBuilder(doc); foreach (var key in dic.Keys)
{
var repStr = string.Format("{0}", key); if (key == "$合同内容$")
{
doc.Range.Replace(repStr, "", false, false);
Book book = doc.Range.Books[0];
builder.MoveToBook(book.Name);
builder.InsertHtml(dic[key]);
}
else if (key == "$附件内容$")
{
doc.Range.Replace(repStr, "", false, false);
Book book = doc.Range.Books[0];
builder.MoveToBook(book.Name);
builder.InsertHtml(dic[key]);
}
else
{
doc.Range.Replace(repStr, dic[key], false, false);
}
}现在遇到个问题,二个定位到了一起。doc.Range.Books[1]肯定是错的。怎么正确分别定位