-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Sudha0829
Message 2 in Discussion
Hi Place a button and name it as print. under print button click event write
the following code as below. Private Sub btnPrint_Click(ByVal sender As Object,
ByVal e As System.EventArgs) Handles btnPrint.Click
rptDoc.PrintOptions.PrinterName = ""
rptDoc.PrintOptions.PaperSize = CrystalDecisions.[Shared].PaperSize.PaperA4
rptDoc.PrintOptions.PrinterDuplex =
CrystalDecisions.[Shared].PrinterDuplex.Default
rptDoc.PrintToPrinter(1, True, 1, 999)
End Sub and for export also place one button name it as export and u can use
the following code as below. Private Sub exp_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles exp.Click
Dim ExportPath As String
Dim ExpFileName As String
Dim ExportedFileName As String
If txtLocation.Text = "" Then
ExportPath = "C:\"
Else
ExportPath = txtLocation.Text
End If
If directory.Exists(ExportPath) = False Then
directory.CreateDirectory(ExportPath)
End If
ExpFileName = txtfilename.Text
crExportOptions = rptDoc.ExportOptions
crDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
Select Case ddlexport.SelectedItem.Text 'this contains the value of the
selected export format.
Case "Rich Text (RTF)"
ExportedFileName = ExpFileName + ".rtf"
crDiskFileDestinationOptions.DiskFileName = ExportPath + "\" + ExportedFileName
With rptDoc.ExportOptions
ExportDestinationType = crexporttype.DiskFile
ExportFormatType = crexportformattype.RichText
DestinationOptions = crDiskFileDestinationOptions
End With
Case "Portable Document (PDF)"
ExportedFileName = ExpFileName + ".pdf"
crDiskFileDestinationOptions.DiskFileName = ExportPath + "\" + ExportedFileName
With rptDoc.ExportOptions
ExportDestinationType = crexporttype.DiskFile
ExportFormatType = crexportformattype.PortableDocFormat
DestinationOptions = crDiskFileDestinationOptions
End With
Case "MS Word (DOC)"
ExportedFileName = ExpFileName + ".doc"
crDiskFileDestinationOptions.DiskFileName = ExportPath + "\" + ExportedFileName
With rptDoc.ExportOptions
ExportDestinationType = crexporttype.DiskFile
ExportFormatType = crexportformattype.WordForWindows
DestinationOptions = crDiskFileDestinationOptions
End With
Case "MS Excel (XLS)"
ExportedFileName = ExpFileName + ".xls"
crDiskFileDestinationOptions.DiskFileName = ExportPath + "\" + ExportedFileName
With rptDoc.ExportOptions
ExportDestinationType = crexporttype.DiskFile
ExportFormatType = crexportformattype.Excel
DestinationOptions = crDiskFileDestinationOptions
End With
End Select
Try
rptDoc.Export()
txtLocation.Text = ""
txtfilename.Text = ""
Response.Write("<font face='Verdana' size='2'>")
lblheading.Text = " Report file is exported to " + ExportPath + " " + " as " +
"" + ExportedFileName
Response.Write("</font>")
Catch err1 As Exception
Response.Write("<br>")
Response.Write(err1.Message.ToString)
End Try
End Sub import the following name spaces. Dim tblLogOnInfo As New
CrystalDecisions.Shared.TableLogOnInfo
Dim table As CrystalDecisions.CrystalReports.Engine.Table
Private rptDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Private crDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions
Private crExportOptions As CrystalDecisions.Shared.ExportOptions
Private directory As System.IO.Directory
Private crexporttype As CrystalDecisions.Shared.ExportDestinationType
Private crexportformattype As CrystalDecisions.Shared.ExportFormatType try the
above code. if u need any clarification plz. revert back. Regards Sudha.
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]