davoman
asked on
exporting to excel through crviewr
hi i hope this is an easy one I am using crystal 8.5 and vb 6.0 using a crviewer in vb 6.0 i am exporting to excel.
This works fine except there are no column headings. Yet here are when i open the report in crystal and export.
Is there there a quick way to get the column headings
This works fine except there are no column headings. Yet here are when i open the report in crystal and export.
Is there there a quick way to get the column headings
ASKER
Public Sub ShowReportsExcel(ByVal strquery As String, strpath As String, strOutput As String)
On Error GoTo Error_check
Dim CRVAppl As CRAXDRT.Application
Dim CRReport As CRAXDRT.Report
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set CRReport = Nothing
Set CRVAppl = New CRAXDRT.Application
Set CRReport = CRVAppl.OpenReport(strpath )
CRReport.DiscardSavedData
cn.ConnectionString = "Provider = SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;" & _
"Data Source=Server1;" & _
"Initial Catalog=FordContact"
cn.Open
rs.Open strquery, cn, adOpenKeyset
CRReport.Database.SetDataS ource rs
Screen.MousePointer = vbHourglass
CRReport.ExportOptions.Des tinationTy pe = crEDTDiskFile
CRReport.ExportOptions.For matType = crEFTExcel80
CRReport.ExportOptions.For matType = crEFTExcel80Tabular
CRReport.ExportOptions.Dis kFileName = "c:\my documents\" & strOutput
CRReport.Export False
Screen.MousePointer = vbDefault
MsgBox "Your report has been exported to c:\my documents\" & strOutput
Else
MsgBox "There were no records to show or the report could not be created"
Exit Sub
End If
Error_out:
Exit Sub
Error_check:
MsgBox "There has been and error. Please see the system administrator" & vbCr & vbCr & Err.Number & vbCr & Err.Description
Resume Error_out
End Sub
The code created with the help of your good self mimcc :)
On Error GoTo Error_check
Dim CRVAppl As CRAXDRT.Application
Dim CRReport As CRAXDRT.Report
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set CRReport = Nothing
Set CRVAppl = New CRAXDRT.Application
Set CRReport = CRVAppl.OpenReport(strpath
CRReport.DiscardSavedData
cn.ConnectionString = "Provider = SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;" & _
"Data Source=Server1;" & _
"Initial Catalog=FordContact"
cn.Open
rs.Open strquery, cn, adOpenKeyset
CRReport.Database.SetDataS
Screen.MousePointer = vbHourglass
CRReport.ExportOptions.Des
CRReport.ExportOptions.For
CRReport.ExportOptions.For
CRReport.ExportOptions.Dis
CRReport.Export False
Screen.MousePointer = vbDefault
MsgBox "Your report has been exported to c:\my documents\" & strOutput
Else
MsgBox "There were no records to show or the report could not be created"
Exit Sub
End If
Error_out:
Exit Sub
Error_check:
MsgBox "There has been and error. Please see the system administrator" & vbCr & vbCr & Err.Number & vbCr & Err.Description
Resume Error_out
End Sub
The code created with the help of your good self mimcc :)
ASKER
rs.Open strquery, cn, adOpenKeyset
If rs.RecordCount > 0 Then
CRReport.Database.SetDataS ource rs
sorry missed a bit
If rs.RecordCount > 0 Then
CRReport.Database.SetDataS
sorry missed a bit
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just the job!! Thanks once again
Glad to help
mlmcc
mlmcc
mlmcc