Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
2.78/5 (3 votes)
See more:
hi...
i creating report development in vb.net,i want to save the rdlc report automatically in pdf format.pls send your code..
Posted
Updated 21-Apr-19 9:44am

I can help with the export, not sure how to print - and I only have a C# example:

EXPORT TO EXCEL OR PDF

There is a button on the report allowing the user to export to excel or pdf. However, if you want to force an export using code, just add this code:

C#
private void exportToExcel(string DestWhereExcelFileWillBe)

{

System.IO.FileInfo fi = new System.IO.FileInfo(DestWhereExcelFileWillBe);

if (fi.Exists) fi.Delete();

Warning[] warnings;

string[] streamids;

string mimeType, encoding, filenameExtension;

byte[] bytes = reportViewer1.LocalReport.Render( "Excel", null, out mimeType, out encoding, out filenameExtension,

out streamids, out warnings);

System.IO.FileStream fs = System.IO.File.Create(DestWhereExcelFileWillBe);

fs.Write(bytes, 0, bytes.Length);

fs.Close();

}



or VB.Net Code Example Here

The code I use to Generate a single report as a PDF is:

VB
Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing

Dim streamids As String() = Nothing

Dim mimeType As String = Nothing

Dim encoding As String = Nothing

Dim extension As String = Nothing

Dim deviceInfo As String

Dim bytes As Byte()

Dim lr As New Microsoft.Reporting.WebForms.LocalReport

deviceInfo = "<deviceinfo><simplepageheaders>True</simplepageheaders></deviceinfo>"

bytes = ReportViewer1.LocalReport.Render("PDF", deviceInfo, mimeType, encoding, extension, streamids, warnings)

Response.ClearContent()

Response.ClearHeaders()

Response.ContentType = "application/pdf"

Response.BinaryWrite(bytes)

Response.Flush()

Response.Close()


[Edit by MK] Solution Source
 
Share this answer
 
v4
Comments
fjdiewornncalwe 16-Aug-13 9:51am    
If you are going to copy/paste a solution from another source (in this case FROM HERE) then please cite the source.
This problem is solved see the solution means go to

How to save RDLC report in Pdf format in vb.net windows application[^]
 
Share this answer
 
i doing same code for here My code:
VB
Imports Microsoft.Reporting.WinForms
Public Class Form1
    Public Property strReport As String
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.companyTableAdapter.Fill(Me.invoicedbDataSet.company)
        Dim rptDataSource As ReportDataSource
        Try
            With Me.ReportViewer1.LocalReport
                .DataSources.Clear()
            End With

            Dim ds As New report.invoicedbDataSet
            Dim da As New report.invoicedbDataSetTableAdapters.companyTableAdapter
            da.Fill(ds.company)
            rptDataSource = New ReportDataSource("DataSet1", ds.Tables("company"))
            Me.ReportViewer1.LocalReport.DataSources.Add(rptDataSource)
            Me.ReportViewer1.RefreshReport()

        Catch ex As Exception
            MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        Me.ReportViewer1.RefreshReport()
    End Sub
End Class
 
Share this answer
 
v3
Comments
Tarhe 28-Aug-15 0:16am    
I can't find where this piece of code save reports to PDF programmatically.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900