Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

exporting to excel through crviewr

Posted on 2003-03-30
6
Medium Priority
?
270 Views
Last Modified: 2011-09-20
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
0
Comment
Question by:davoman
  • 3
  • 3
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 8235036
How are you exporting the data from VB?  What is the code?

mlmcc
0
 
LVL 1

Author Comment

by:davoman
ID: 8235083
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.SetDataSource rs


Screen.MousePointer = vbHourglass
CRReport.ExportOptions.DestinationType = crEDTDiskFile
CRReport.ExportOptions.FormatType = crEFTExcel80
CRReport.ExportOptions.FormatType = crEFTExcel80Tabular


CRReport.ExportOptions.DiskFileName = "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 :)
0
 
LVL 1

Author Comment

by:davoman
ID: 8235089
rs.Open strquery, cn, adOpenKeyset

If rs.RecordCount > 0 Then
CRReport.Database.SetDataSource rs

sorry missed a bit

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
LVL 101

Accepted Solution

by:
mlmcc earned 400 total points
ID: 8235101
I think this line causes you to export only the data and not the columns headers

CRReport.ExportOptions.FormatType = crEFTExcel80Tabular

Try without that line.

mlmcc
0
 
LVL 1

Author Comment

by:davoman
ID: 8235107
Just the job!! Thanks once again
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8235460
Glad to help

mlmcc
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question