0

How to Sub report Export using vb.net 2008?

Main report already Properly export as PDF Format.

But my need also export as pdf is - 2 no and 3 No report

how this possible? enter image description here

Code is-

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 Answer 1

0

you need to define a new data table and set subreport datasource as below:

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

then you can use one line to export to PDF or MS- Word what ever you need as

  cryRpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, True, "Your File Name")
1
  • Assalalualikum, Dear vai, plz write me details code. Dec 30, 2015 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.