Sugeng rawuh

Print PDF crystal report VB

To print Crystal Reports to PDF for specific pages, such as page 1 and page 2, you can use the Crystal Reports ExportToDisk method with the PDF format. Here's how you can do it in your VB.NET code:

Assuming you have a Crystal Report Viewer control named CrystalReportViewer1 on your form and you want to export page 1 and page 2 to separate PDF files:

Imports System.IO

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared


Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        ' Load and display the Crystal Report as shown in the previous example.

    End Sub


    Private Sub ExportToPDFPagesButton_Click(sender As Object, e As EventArgs) Handles ExportToPDFPagesButton.Click

        Dim rpt As New SiswaReport ' Replace with the actual report name.


        ' Export page 1 to a PDF file.

        Dim exportOptions As New ExportOptions()

        Dim pdfOptions As New PdfRtfWordFormatOptions()

        pdfOptions.FirstPageNumber = 1 ' Set the first page to export.

        pdfOptions.LastPageNumber = 1 ' Set the last page to export.

        exportOptions.ExportFormatOptions = pdfOptions

        exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat


        ' Specify the path and file name for the PDF file.

        Dim pdfPathPage1 As String = "Page1.pdf"


        ' Export the report to PDF (page 1).

        rpt.ExportToDisk(ExportFormatType.PortableDocFormat, pdfPathPage1)


        ' Export page 2 to a PDF file.

        pdfOptions.FirstPageNumber = 2 ' Set the first page to export.

        pdfOptions.LastPageNumber = 2 ' Set the last page to export.


        ' Specify the path and file name for the PDF file.

        Dim pdfPathPage2 As String = "Page2.pdf"


        ' Export the report to PDF (page 2).

        rpt.ExportToDisk(ExportFormatType.PortableDocFormat, pdfPathPage2)


        ' Optionally, you can open the PDF files using the default PDF viewer.

        If File.Exists(pdfPathPage1) Then

            Process.Start(pdfPathPage1)

        End If


        If File.Exists(pdfPathPage2) Then

            Process.Start(pdfPathPage2)

        End If

    End Sub

End Class

Share:

Setting laravel 9 localhost htdoc


sudo chmod  -R 777 storage
sudo chmod -R 777 bootstrap
Share:

Visual Basic, Membuat laporan data siswa

To create a report using Crystal Reports in Visual Basic for a database table named "siswa" with columns "id," "nama," and "alamat," you'll need to follow these steps:

Step 1: Create a Windows Forms Application

  • Open Visual Studio 2015.
  • Create a new Windows Forms Application project.

Step 2: Install Crystal Reports

If you haven't already installed Crystal Reports for Visual Studio, you can do so using the Visual Studio installer.

Step 3: Add a Crystal Report

  • Right-click on your project in the Solution Explorer.
  • Select "Add" > "New Item..."
  • In the "Add New Item" dialog, search for "Crystal Reports."
  • Select "Crystal Report" and name it, e.g., "SiswaReport.rpt."
  • Click "Add."

Step 4: Design the Crystal Report

  • In the Crystal Reports Designer, go to "Database" > "Database Expert..."
  • In the "Database Expert" dialog, select your data source, usually "OLE DB (ADO)" for a database.
  • Connect to your database and select the "siswa" table.
  • Add the fields "id," "nama," and "alamat" to the report.

Step 5: Create a Form to Display the Report

  • Add a Windows Form to your project if you don't have one.
  • Drag and drop a CrystalReportViewer control onto the form. Resize it as needed.
  • In the Properties window, set the ReportSource property of the CrystalReportViewer to your report, e.g., "SiswaReport.rpt."

Step 6: Load Data into the Report

You need to write code to load data from the database into the report. Here's a basic example using ADO.NET:

vb.net


Copy code

SS. Source code


Replace "Your_Connection_String_Here" with the appropriate connection string to your database.

Step 7: Run the Application

Build and run your Windows Forms application, and the Crystal Report with data from the "siswa" table should be displayed in the CrystalReportViewer.

Make sure you have the necessary Crystal Reports runtime installed on the target machine if you plan to deploy the application outside of your development environment.

Share:

Tonton video



Yuk, SUBSCRIBE

omfiki.blogspot.com