我在vb .net应用程序中创建了一个Crystal报表,它在我的开发机器上运行良好。但是,为了使报告在用户计算机上正常工作,我必须创建一个包含.rpt文件的额外文件夹。我的问题是,如何嵌入报告以使其包含在.exe?
中这是我的代码:
Public Sub PreviewPickList(ByVal PickListNo As Integer, Optional ByVal ShopOrderId As Integer = 0)
Dim cryRpt As New ReportDocument
cryRpt.Load(Application.StartupPath & "\Inventory\PickListReportCR.rpt")
PickListViewer.ReportSource = cryRpt
Dim dtPickList As New DataTable
dtPickList = DTEngines.GetPickList(PickListNo, ShopOrderId)
cryRpt.SetDataSource(dtPickList)
PickListViewer.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None
PickListViewer.Refresh()
Me.Show()
End Sub
很明显,cryRpt.load行指定了一个特定的路径,但当我将其更改为:
cryRpt.Load("PickListReportCR.rtp")
或
cryRpt.Load(Application.StartupPath & "\PickListReportCR.rpt")
两种选择都不起作用。
我已经将属性设置为" Embedded Resource"和"不要复制"
感谢您的帮助。
答案 0 :(得分:0)
dim doc as new ReportDocument
doc.Load(Server.MapPath("PickListReportCR.rpt"))
doc.SetDatabaseLogon(ReportServerDSUserName, ReportServerDSPassword,ReportServerDomain, "DatabseName", false)
CrystalReportViewer1.ReportSource = doc;
试试这个......