Home > Archive > Visual Basic Crystal Reports > January 2006 > run report then export
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
run report then export
|
|
| Abraham Andres Luna 2006-01-23, 7:07 pm |
| using Crystal Reports 8.5 ActiveX Designer Run Time Library (CRAXDRT.DLL),
what method would i call to pull the data before i export
this is my c# code:
ApplicationClass appCrystal = new ApplicationClass();
string strFileName = @"C:\report.prt";
Report rReport = appCrystal.OpenReport(strFileName,
CROpenReportMethod.crOpenReportByDefault);
ExportOptionsClass eoReport = (ExportOptionsClass)rReport.ExportOptions;
eoReport.DestinationType = CRExportDestinationType.crEDTDiskFile;
eoReport.DiskFileName = @"C:\pdfs\" +
Path. GetFileNameWithoutExtension(strFileName)
+ ".pdf";
eoReport.FormatType = CRExportFormatType.crEFTPortableDocFormat;
rReport.Export(false); //this line fails because their is no data
while (appCrystal.CanClose())
{
Thread.Sleep(3000);
}
rReport = null;
appCrystal = null;
however, this code will not work unless i save the data with the report
i can't do that because the report data changes constantly
ty for your help
| |
| Shariq 2006-01-23, 7:07 pm |
| I can provide you with VB sample code; if interested.
"Abraham Andres Luna" wrote:
> using Crystal Reports 8.5 ActiveX Designer Run Time Library (CRAXDRT.DLL),
> what method would i call to pull the data before i export
>
> this is my c# code:
> ApplicationClass appCrystal = new ApplicationClass();
> string strFileName = @"C:\report.prt";
> Report rReport = appCrystal.OpenReport(strFileName,
> CROpenReportMethod.crOpenReportByDefault);
> ExportOptionsClass eoReport = (ExportOptionsClass)rReport.ExportOptions;
> eoReport.DestinationType = CRExportDestinationType.crEDTDiskFile;
> eoReport.DiskFileName = @"C:\pdfs\" +
> Path. GetFileNameWithoutExtension(strFileName)
+ ".pdf";
> eoReport.FormatType = CRExportFormatType.crEFTPortableDocFormat;
> rReport.Export(false); //this line fails because their is no data
> while (appCrystal.CanClose())
> {
> Thread.Sleep(3000);
> }
> rReport = null;
> appCrystal = null;
>
> however, this code will not work unless i save the data with the report
> i can't do that because the report data changes constantly
> ty for your help
>
>
>
| |
| Abraham Andres Luna 2006-01-23, 7:07 pm |
| yes please
| |
| Shariq 2006-01-24, 7:07 pm |
| Try
Dim frmReport As New CR_SNLogViewer
Dim ParameterFields As CrystalDecisions.Shared.ParameterFields
Dim ParameterField As CrystalDecisions.Shared.ParameterField
Dim ParameterRangeValue As
CrystalDecisions.Shared.ParameterDiscreteValue
ParameterFields = New CrystalDecisions.Shared.ParameterFields
ParameterField = New CrystalDecisions.Shared.ParameterField
ParameterField.ParameterFieldName = "Job"
ParameterRangeValue = New
CrystalDecisions.Shared.ParameterDiscreteValue
If gsJobNumber = Nothing Then gsJobNumber = 0
ParameterRangeValue.Value = gsJobNumber
ParameterField.CurrentValues.Add(ParameterRangeValue)
ParameterFields.Add(ParameterField)
CrystalReportViewer1.ParameterFieldInfo = ParameterFields
CrystalReportViewer1.ReportSource = frmReport
CrystalReportViewer1.Refresh()
ExportReport()
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Information,
"frmCR_SNReport_Load")
End Try
Private Sub ExportReport()
Dim crReportDocument As ReportDocument
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions
Dim Fname As String
Dim InputFileName As String = "SNReport.rpt"
Dim InputPath As String = gsExportPath & "\Reports\"
Dim OutputPath As String = gsExportPath & "\Output\"
Dim InputFilePath As String = InputPath & InputFileName
Try
crReportDocument = New ReportDocument
crReportDocument.Load(InputFilePath)
Fname = OutputPath & gsJobNumber & "_" & Format(Today.Month,
"00") & Format(Today.Day, "00") & Today.Year & ".pdf"
gsImportFilename = InputFilePath
Dim pv_Date As New CrystalDecisions.Shared.ParameterValues
Dim pdv_DateRange As New
CrystalDecisions.Shared.ParameterDiscreteValue
pdv_DateRange.Value = gsProductNumber
pv_Date.Add(pdv_DateRange)
crReportDocument.DataDefinition.ParameterFields("Product").ApplyCurrentValues(pv_Date)
Dim diskFile_Report As New
CrystalDecisions.Shared.DiskFileDestinationOptions
diskFile_Report.DiskFileName = Fname
crReportDocument.ExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
crReportDocument.ExportOptions.ExportDestinationType =
CrystalDecisions.Shared.ExportDestinationType.DiskFile
crReportDocument.ExportOptions.DestinationOptions =
diskFile_Report
crReportDocument.Export()
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Information, "ExportReport")
End Try
End Sub
"Abraham Andres Luna" wrote:
> yes please
>
>
>
|
|
|
|
|