请问,winform下如何将一条新闻从数据库中提取出来,然后导出为word。新闻内容为html怎么样转换编码? 就是这样一个简单的问题,我现在还没有搞定,只是可以导出word,但是不能实现html转换成word编码,导出来之后乱得一塌糊涂。全部都是标签。大家有什么办法么?商量一下。谢谢了,很急。后天就要交的,救命啊! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string content1=""; conn=connc.getconn(); string sql="select * from news where id=969"; SqlCommand cmd=new SqlCommand(sql,conn); SqlDataReader readnews=cmd.ExecuteReader(); if (readnews.Read()==true) { content1=readnews.GetString(2); } readnews.Close(); object missing = System.Reflection.Missing.Value; object fileName = "normal.dot"; object newTemplate = false; object docType = 0; object isVisible = true; Word.Document aDoc = WordApp.Documents.Add(ref fileName, ref newTemplate, ref docType, ref isVisible); WordApp.Visible = true; aDoc.Activate(); WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter; WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle; WordApp.Selection.TypeText(content1);这样导出的!? string s = "....";s = System.Text.RegularExpressions.Regex.Replace(s, @"<[^>]+>",""); C# webForm中,如何取MSChart的图片 关于ASP.NET和C# 写了一个c#类,该类在退出程序时发生异常:ObjectDisposedException 紧急求救一个关于OpenFileDialog类的问题 字符串如何转化为16进制 请教高手一个问题,急! web页面,一个Table的<td>中如何让关两个控件重叠啊? ComboBox控件的控制 页面停留5秒后,再Redirect,这5秒如何取得? webapi,如何用DES对全局进行加密? 如何将数据库查询结果在页面上用链接形式显示出来? 如何用C#获得文件夹属性???
conn=connc.getconn();
string sql="select * from news where id=969";
SqlCommand cmd=new SqlCommand(sql,conn);
SqlDataReader readnews=cmd.ExecuteReader();
if (readnews.Read()==true)
{
content1=readnews.GetString(2);
}
readnews.Close();
object missing = System.Reflection.Missing.Value;
object fileName = "normal.dot";
object newTemplate = false;
object docType = 0;
object isVisible = true;
Word.Document aDoc = WordApp.Documents.Add(ref fileName, ref newTemplate, ref docType, ref isVisible);
WordApp.Visible = true;
aDoc.Activate();
WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;
WordApp.Selection.TypeText(content1);这样导出的!?
s = System.Text.RegularExpressions.Regex.Replace(s, @"<[^>]+>","");