我有一份原创的2份报告: offset.rpt和roto.rpt
我需要为这两份报告创建一个新设计(添加新徽标和更改颜色)。 我复制offset.rpt并命名为offset_temp.rpt,我复制roto.rpt并将其命名为roto_temp.rpt
这是我的代码:
Public Sub ViewReport()
Dim i As Integer
i = Main.dgvColorTolerance.CurrentRow.Index
Dim filePath As String
If Main.Process = "ROTO" Then
filePath = Application.StartupPath + "\roto.rpt"
If Main.lblcheckuni.Text.Contains("NEW") Then
filePath = Application.StartupPath + "\roto_temp.rpt"
End If
Else
filePath = Application.StartupPath + "\offset.rpt"
If Main.lblcheckuni.Text.Contains("NEW") Then
filePath = Application.StartupPath + "\offset_temp.rpt"
End If
End If
cryRpt.Load(filePath)
cryRpt.RecordSelectionFormula = " ({command.ID} = " & Main.dgvColorTolerance.Item(Main.dgvColorTolerance.Columns.Count - 1, i).Value & ")"
cryRpt.SetDatabaseLogon("sa_connection", "******")
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Zoom(85)
当我运行它时:错误消息"加载报告失败"当lblcheckuni.text包含" NEW"但如果没有,它运行正常。 我谷歌它和一些说可能文件不存在。但它存在。 请帮忙。谢谢
答案 0 :(得分:1)
获取桌面路径
Dim desktop as string = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
filePath = desktop & "\color_tolerance\ColorTolerance (Win App)\ColorTolerance\" & reportName