高难度啊!各位老大:能把rtf格式转换为html吗?欢迎提出思路!

colorrain 2007-07-09 04:15:06
顶帖散分!!!
...全文
471 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
happywqw 2008-01-07
  • 打赏
  • 举报
回复
1、效果最好的解决方案是通过Word对象进行转换;
2、网上有些类似控件可以使用,不过转换效果都不敢恭维;
3、如果你要精确解析甚至开发自己的控件来卖钱,并且不想依赖Office,那么只有自己解析RTF文件格式了,有关RTF文件格式,可以参考一下以下文章:
《RTF文件格式研究报告》 http://www.cnpopsoft.com/article.asp?id=11
《RTF文件格式规范 v1.7》(全文翻译版本)!http://www.cnpopsoft.com/article.asp?id=18
andylilin 2007-07-11
  • 打赏
  • 举报
回复

'生成Html文件
Function MakeHtml()

Dim str As String
str = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'></head><div align='center'><strong><font size='5'><u>"
str = str + rstRep("ReTitle").Value & "" 'txtReTitle.Text '报表标题

str = str + "</u></font></strong></div><table bordercolor=#000000 border=1 align= Center width= 653 cellspacing= 0 cellpadding= 0><caption><font size=4>"
str = str + rstRep("SubTitle").Value & "" 'txtSubTitle.Text '副标题

str = str + "<br><br></font></caption><td colspan=4><font size=-1> </font><center><font size='-1'>编号:"
str = str + ChangName(rstMain("ID").Value) & "" 'txtGetInfoId.Text '编号

str = str + "<br><br>指令日期: "
str = str + Format(rstMain("ShiLingDate").Value, "yyyy 年 MM 月 dd 日HH 时mm 分") & "" '指令日期

str = str + "</font></center><font size=-1><br>"
str = str + rstRep("TuoGuanDep").Value 'comTuoGuanDep.Text '托管部门

str = str + "<br><br>  敬请贵部根据以下提供的收款人名称、开户行、帐号、到帐日期和划款金额划款。</font></td><tr><td align=Left width='186'><font size=-1> 到帐日期:</font></td><td colspan='3' align=Left><font size=-1>"
str = str + ChangTime(rstMain!GetDate) & "" 'ChangTime(rstMain("GetDate").Value)到帐日期

str = str + "</font></td></tr><tr><td width='186'><font size=-1> 收款人:</font></td><td colspan='3'><font size=-1>"
str = str + rstMain("HuaKuanPerson").Value & ""

str = str + "</font></td></tr>" & vbCrLf & "<tr><td width='186'><font size=-1> 开户行:</font></td><td colspan='3'><font size=-1>"
str = str + rstMain("UseBank").Value & ""

str = str + "</font></td></tr><tr><td align=Left width='186'> 帐号:</td><td colspan='3'>"
str = str + rstMain("AccountNum").Value & ""

str = str + "</td></tr><tr><td width='186'><font size=-1> 划款金额(小写):</font></td><td colspan='3'>"
str = str + "¥" + Format(rstMain("HuaKuanMoney").Value, "##,##0.00") & "" '"¥" + masMoney.Text '

str = str + "</td></tr><tr><td width='186'><font size=-1> 划款金额(大写):</font></td><td colspan='3'><font size=-1>"
str = str + ChangeMoney(rstMain("HuaKuanMoney").Value) & ""

str = str + "</font></td></tr><tr><td colspan=5 height=110 width='649'><font size=-1> 划款金额用途:"
str = str + rstMain("HuaKuanUse").Value & ""

str = str + "<br><br> <br><br><br><br></font></td></tr><tr><td colspan=5 height=110 width='649'><font size=-1> 备注:"
str = str + rstMain("Remark").Value & ""

str = str + "<br><br><br><br><br></font></td></tr><tr><td width=402 height=110><font size=-1> 管理人签章:"

str = str + "<br><br><br><br><br></font></td><td width='244'><font size=-1> 托管人签章:"

str = str + "<br><br><br><br><br></font></td></tr><tr height=60><td width='402'><br></td><td width='417'><font size=-1> 审批人:"

str = str + "</font></td></tr><tr height=60><td width='402'><font size=-1> 复核人:"
str = str & rstMain("ReexaminesPerson").Value & "" 'labRePer.Caption

str = str & "</font></td><td width='244'><font size=-1> 复核人:"

str = str + "</font></td></tr><tr height=60><td width='402'><font size=-1> 经办人:"
str = str + rstMain("ManagesPerson").Value & ""

str = str + "</font></td><td width='244'><font size=-1> 经办人:"

str = str + "</font></td></tr></table></html>"

MakeHtml = str

End Function
一笑拔剑 2007-07-10
  • 打赏
  • 举报
回复
用word的好像有个例子

如果你是自己写会很难的

我看过一个rtf的要插件的
guyehanxinlei 2007-07-10
  • 打赏
  • 举报
回复
有效的实现手段是用代码将rtf格式转换成HTML格式
以下是一段参考:需要引用OFFICE引用
'调用WORD应用程序将.doc格式转化成.rtf格式
'定义word对象
Set oApp = New Word.Application
'定义文档对象
Set oDoc = oApp.Documents.Open(strFile)

'将.doc格式转化成.HTML格式
oDoc.SaveAs App.path & "\data\file.HTML", wdFormatHTML

oDoc.Close False

Set oDoc = Nothing
'转化完毕退出WORD应用程序
oApp.Quit
'释放对象
Set oApp = Nothing
VBAdvisor 2007-07-10
  • 打赏
  • 举报
回复
网上很多这方面的资料。VB完全可以做到.Google"VB rtf to HTML" or "VB convert rtf to HTML"
or "VB rtf HTML"

Good Luck!
colorrain 2007-07-10
  • 打赏
  • 举报
回复
各路英雄,顶贴阿
嗷嗷叫的老马 2007-07-10
  • 打赏
  • 举报
回复
关注一下
colorrain 2007-07-09
  • 打赏
  • 举报
回复
阿勇说的好象有些道理!
自己用代码解析的话,有思路吗
fxy_2002 2007-07-09
  • 打赏
  • 举报
回复
用word 对象加载,然后另存为 html 格式。这样应该比较简单!

自己来解析生成HTML代码的话,估计比较复杂。

CathySun118 2007-07-09
  • 打赏
  • 举报
回复
word就可以转换啊
colorrain 2007-07-09
  • 打赏
  • 举报
回复
有没有不会的阿,有没有想学的阿,有没有做过此类程序的阿。大家一起跟贴啊。跟贴有份!
colorrain 2007-07-09
  • 打赏
  • 举报
回复
这个问题是不是很难哈。难住各位英雄了

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧