+ -
当前位置:首页 → 问答吧 → HTML字符串,转化为Word文档

HTML字符串,转化为Word文档

时间:2011-12-13

来源:互联网

使用“Microsoft.Office.Interop.Word”将“HTML字符串”,转化为“Word文档”,方法如下:

public void CreateWordFile()
  {
  object oMissing = System.Reflection.Missing.Value;
  Microsoft.Office.Interop.Word._Application oWrod = new Microsoft.Office.Interop.Word.Applicatio();
  oWrod.Visible = true;
  Microsoft.Office.Interop.Word._Document oDoc = oWrod.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);

  //Add new table
  object start = 0;
  object end = 0;
  Microsoft.Office.Interop.Word.Range tableLocation = oDoc.Range(ref start, ref end);
  oDoc.Tables.Add(tableLocation, 1, 1, ref oMissing, ref oMissing);
  oDoc.Tables[1].Cell(1, 1).Range.Text = content;
   
问题:
“content”是HTML字符串,现在可以将字符串“直接输出到Word”。但是输出的文本内容并“没有按照HTML中标签定义的格式显示”,而是直接把这些HTML标签也输出了。

现在的问题是:如何才能使输出的Word中的文本内容“按照HTML字符串中的标签定义的格式”显示,而不是直接把标签输出出来。怎么办呢??? //oDoc.Tables[1].Cell(2, 2).Range.Text = "新闻字符串";
  }

作者: starryleader   发布时间: 2011-12-13

该回复于2011-12-13 13:51:15被管理员删除

  • 对我有用[0]
  • 丢个板砖[0]
  • 引用
  • 举报
  • 管理
  • TOP
#2楼 得分:0回复于:2011-12-13 13:45:25
http://ufo-crackerx.blog.163.com/blog/static/1130787782011111392519621/

作者: starryplayer   发布时间: 2011-12-13

我会 WORD转化HTML

作者: crackdung   发布时间: 2011-12-13

http://topic.csdn.net/u/20100121/16/c4f9bae4-5f8e-482e-9297-1d62dcaf85c4.html

作者: guanyelong   发布时间: 2011-12-13

热门下载

更多