以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 【富文本编辑】怎么把用代码读取到的Word或者text文件内容,赋值到富文本编辑框里面进行编辑并保存为新的文件呢? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=160069) |
||||
-- 作者:cnsjroom -- 发布时间:2021/1/19 13:12:00 -- 【富文本编辑】怎么把用代码读取到的Word或者text文件内容,赋值到富文本编辑框里面进行编辑并保存为新的文件呢? 【富文本编辑】怎么把用代码读取到的Word或者text文件内容,赋值到富文本编辑框里面进行编辑并保存为新的文件呢? 想实现读取文本按钮时,就对应将读取到的文本内容赋值到富文本框编辑里 编辑完毕后,想实现打开网页,显示的富文本框编辑里面有内容对应为文件读取后或者修改得到的内容,并且可以单独保存为别的Word文件或者其他格式文件 麻烦老师们帮忙看看 谢谢!
富文本编辑采用的是kindeditor
此主题相关图片如下:001.png 打开网页后,网页页面要能够对应显示所得到的编辑框内容 当然为空白 当前读取文件代码如下: Dim app As New MSWord.Application Dim wb2 As WinForm.WebBrowser = e.Form.Controls("WebBrowser2") Dim t1 As WinForm.TextBox = e.Form.Controls("TextBox1") try Dim dlg As New OpenFileDialog dlg.Filter = "|*.*" If dlg.ShowDialog =DialogResult.OK Then Dim fl As String = dlg.FileName wb2.Address=fl Dim doc = app.Documents.Open(dlg.fileName) Dim count = Doc.Characters.Count Dim rng As MSWord.Range = Doc.Range(Start:=0, End:=count) t1.text=rng.Text.replace(chr(13), vbcrlf) End If app.Quit catch ex As exception msgbox(ex.message) app.Quit End try [此贴子已经被作者于2021/1/19 13:17:53编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2021/1/19 13:52:00 -- 自己看文档:http://kindeditor.net/doc.php |
||||
-- 作者:有点蓝 -- 发布时间:2021/1/19 14:02:00 -- 看看这个例子:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=49051&replyID=&skin=1 |
||||
-- 作者:cnsjroom -- 发布时间:2021/1/19 14:17:00 -- 回复:(有点蓝)看看这个例子:http://www.foxtable.... 经过学习,没有弄明白呢 红色部分失效 麻烦老师多多指导下 谢谢!
瓜哥百例之编辑器的全部代码: 表事件
表A_PrepareEdit
e.Cancel = True
表A_DoubleClick
Forms("瓜哥百例之编辑器").open()
窗口与控件事件
瓜哥百例之编辑器_AfterLoad
Dim web As WinForm.WebBrowser = e.Form.Controls("WebBrowser1") \'web.OfficeToolBar = True web.Address = "http://qqzg.org/mysystem/editor/examples/default.html" ‘这个地址失效,我实在没有看懂这个是啥实现的’
e.Form.Controls("TextBox1").text = Tables("表A").current("第一列") e.Form.TimerEnabled = True e.Form.TimerInterval = 500
瓜哥百例之编辑器_Button1_Click
Tables("表A").current("第一列")=e.Form.Controls("TextBox1").text Tables("表A").current.save() Vars("编辑器校验")=0 e.Form.close
瓜哥百例之编辑器_Button2_Click
Vars("编辑器校验")=0 e.Form.close
瓜哥百例之编辑器_TimerTick
If e.form.ExistControl("WebBrowser1") Then If e.form.controls("WebBrowser1").basecontrol.Document.Window.Frames.Count > 0 Then If Vars("编辑器校验")=0 Then e.form.controls("WebBrowser1").basecontrol.Document.Window.Frames(0).Document.body.InnerHtml = Tables("表A").current("第一列") Vars("编辑器校验")=1 End If e.Form.Controls("TextBox1").text = e.form.controls("WebBrowser1").basecontrol.Document.Window.Frames(0).Document.body.InnerHtml End If End If |
||||
-- 作者:有点蓝 -- 发布时间:2021/1/19 14:24:00 -- 改为自己本机的html编辑器网页地址 |