子报告在vb.net中导出

时间:2015-12-29 08:10:03

标签: vb.net crystal-reports

如何使用vb.net 2008子报告导出?

主报告已正确导出为PDF格式。

但我的需要也是出口,因为pdf是 - 2 no and 3 No report

这怎么可能? enter image description here

代码是

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ExecuteQuery("Execute dbo.BatchWiseIssue @OrderID=" & OrderGridLookUpEdit.EditValue, cnn) filterstring = "{Command.OrderID} = " & OrderGridLookUpEdit.EditValue 'Call Report Dim MyReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = New OrderAllStatusSummery_2 ShowReport(MyReport, filterstring, CrystalReportViewer1) 'Export Dim CrExportOptions As ExportOptions Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions() Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions() CrDiskFileDestinationOptions.DiskFileName = "D:\Imrul_XML\PDF\crystalExport.pdf" CrExportOptions = MyReport.ExportOptions With CrExportOptions .ExportDestinationType = ExportDestinationType.DiskFile .ExportFormatType = ExportFormatType.PortableDocFormat .DestinationOptions = CrDiskFileDestinationOptions .FormatOptions = CrFormatTypeOptions End With MyReport.Export() Dim pdfFile As String = CrDiskFileDestinationOptions.DiskFileName 'Call Outlok Dim Outl As Object Outl = CreateObject("Outlook.Application") If Outl IsNot Nothing Then Dim omsg As Object omsg = Outl.CreateItem(0) omsg.subject = "Hello" omsg.body = "Dear Sir," & vbNewLine & "" & vbNewLine & "plz check this file......." & vbNewLine & "" & vbNewLine & "" & vbNewLine & "" & vbNewLine & "With Best Regards," & vbNewLine & "------------" & vbNewLine & NameTextBox.Text & vbNewLine & DesignationTextBox.Text & vbNewLine & "Sparkle Knit Composite Ltd." & vbNewLine & "Asulia, Savar, Bangladesh" omsg.Attachments.Add(pdfFile) omsg.Display(False) End If End Sub

1 个答案:

答案 0 :(得分:0)

您需要定义一个新数据表并设置子报表数据源,如下所示:

 Dim DT As DataTable = "Your Method or Query"
 cryRpt.Subreports("Sub Report Name as in report").SetDataSource(DT)

然后您可以使用一行导出到PDF或MS-Word,无论您需要什么

  cryRpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, True, "Your File Name")