-- 作者:cnsjroom
-- 发布时间:2022/3/13 16:13:00
-- 如何将excel word文件直接转换成PDF
如何将excel word文件直接转换成PDF
excel word文件是在直接上传的时候就已经成型了,但是为了避免他人修改 想直接实现转换成pdf 只提供阅读 不提供修改
麻烦老师帮忙看看红色部分代码怎么完善呢?
If Tables(e.Form.Name & "_table1").Current Is Nothing Then Return End If Dim dr As DataRow = Tables(e.Form.Name & "_table1").Current.DataRow Dim fl As String = ProjectPath & dr("文件名") & "." & dr("文件类型") If FileSys.FileExists(fl) AndAlso CRCCheckFile(fl) = dr.SQLGetValue("CRC值") Then \'如果本地存在同名文件且CRC校验值相同 \'则直接使用本地文件 Else \'否则从数据库提取文件 If dr.SQLLoadFile("附件",fl) = False Then \'如果提取文件失败 Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) Return End If End If
Dim bbb As String =dr("文件类型") Dim tb As WinForm.TabControl = e.Form.Controls("TabControl1") Dim wb As WinForm.WebBrowser = e.Form.Controls("WebBrowser1") Dim pc As WinForm.PictureBox = e.Form.Controls("PictureBox1") If bbb.Contains("bmp") Or bbb.Contains("jpg") Or bbb.Contains("gif") Or bbb.Contains("png") Then tb.SelectedIndex=0 pc.Image = GetImage(fl) Else If bbb.Contains("doc") Or bbb.Contains("docx") Or bbb.Contains("xls") Or bbb.Contains("xlsx") Then Dim fl1 As String = ProjectPath & dr("文件名") & "." & dr("文件类型")\'指定目标文件 Dim fl2 As String = ProjectPath & dr("文件名") & ".pdf" \'指定目标PDF文件 \'Dim wrt As New WordReport(fl) \'定义一个WordReport \'wrt.Build() \'逐行生成报表 \'wrt.SaveToPDF(fl2) \'保存为PDF文件 \'wrt.Quit() \'退出 wb.Address = fl2 tb.SelectedIndex=1 Else If bbb.Contains("txt") Or bbb.Contains("pdf") Then tb.SelectedIndex=1 wb.Address = fl Else Dim Proc As New Process \'打开文件 Proc.File = fl Proc.Start() End If
|