Hi ,
I am using below code to export crystal report (asp.net 2003).. It is opening the file in pdf as i want, but my report has 3 pages and in pdf it shows only 2 pages...can anyone help on this.
Code:
Private Sub Btn_Export_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Export.Click
Try
Me.Crystalreportviewer1.ParameterFieldInfo.Clear()
If Me.txtSTdate.Text.Trim.Length > 0 Then
Dim fs As IO.FileStream
Dim FileSize As Long
Dim crDataDef As DataDefinition
Dim oDest As New CrystalDecisions.Shared.DiskFileDestinationOptions
Dim reportName As String = Now.Day.ToString & "_" & Now.Month.ToString() & "_" & Now.Year.ToString() & "_" & Now.Hour.ToString & "_" & Now.Minute.ToString & "_" & Now.Second.ToString() & "_" & Now.Millisecond.ToString()
Dim ExportFileName As String = Server.MapPath("/") & ConfigurationSettings.AppSettings("ExportDir") & reportName & ".pdf"
crDataDef = crReportDocument.DataDefinition
crReportDocument.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
crReportDocument.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
oDest.DiskFileName = ExportFileName
crReportDocument.ExportOptions.DestinationOptions = oDest
Dim ParamFields As ParameterFields = Me.Crystalreportviewer1.ParameterFieldInfo
Dim Per As New ParameterField
Per.ParameterFieldName = "Date"
Dim ParamCurrentValues As New ParameterValues
Dim Period_Value As New ParameterRangeValue
Period_Value.StartValue = Me.txtSTdate.Text
Period_Value.EndValue = Me.txtCLdate.Text
Per.CurrentValues.Add(Period_Value)
ParamFields.Add(Per)
'Set Division Paramter
Dim GetDivisionValues As String
GetDivisionValues = Trim(Request.Form(ddl_division.UniqueID))
Per = New ParameterField
Per.ParameterFieldName = "Division"
Dim Division_Value As New ParameterDiscreteValue
If GetDivisionValues = "Select All" Then
Division_Value.Value = "*"
Else
Division_Value.Value = GetDivisionValues
End If
Per.CurrentValues.Add(Division_Value)
ParamFields.Add(Per)
crReportDocument.Export()
'Build Target Filename
'Send the file to the user that made the request
Response.Clear()
Response.Buffer = True
Response.AddHeader("Content-Type", "application/pdf")
fs = New IO.FileStream(ExportFileName, IO.FileMode.Open)
FileSize = fs.Length
Dim bBuffer(CInt(FileSize)) As Byte
fs.Read(bBuffer, 0, CInt(FileSize))
fs.Close()
Response.BinaryWrite(bBuffer)
Response.Flush()
Response.Close()
End If
Catch ex As Exception
lblError.Text = ex.Message.ToString
End Try
End Sub
Thanks to help.