?
Solved

Exporting to excel using VB and CRviewer

Posted on 2003-02-26
7
Medium Priority
?
1,075 Views
Last Modified: 2012-06-27
I am using Visual basic and the CRviewer with Crystal 8.5
for my reports. But some of the reports i want to be exported straight to excel without the user even seing them. Below is the code i am currently using. Can this be easily modified to export straight to excel. Sorry these are all the points i have left

Dim CRVAppl As CRAXDRT.Application
Dim CRReport As CRAXDRT.Report
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset



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

If rs.RecordCount > 0 Then
While rs.EOF = False
    CRReport.Database.SetDataSource rs
rs.MoveNext
Wend

Screen.MousePointer = vbHourglass

frmMAinReports.CRViewer1.ReportSource = CRReport
frmMAinReports.CRViewer1.ViewReport
frmMAinReports.Show
CRReport.Expor

Screen.MousePointer = vbDefault
0
Comment
Question by:davoman
  • 5
  • 2
7 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 8029858
Yes it can

Screen.MousePointer = vbHourglass

CRReport.ExportOptions.DestinationType = crDiskFile
CRReport.ExportOptions.FormatType = crEFTExcel
CRReport.ExportOptions.DiskFileName = "C:\myreport"
CRReport.Export False

Some of the CR constants may be wrong but you should be able to figure them out.  I think I have all the lines of code there.

The other lines
frmMAinReports.CRViewer1.ReportSource = CRReport
frmMAinReports.CRViewer1.ViewReport
frmMAinReports.Show
CRReport.Expor
 aren't needed unless you want to display the report.


mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8029894
Just found an example.  The only mistake
was

CRReport.ExportOptions.DestinationType = crEDTDiskFile

mlmcc
0
 
LVL 1

Author Comment

by:davoman
ID: 8032045
Drat i am getting a variable not defined error on crEFTExcel

I'm new to programming crystal like this is there anywhere i can get a list of the constants. Thanks for all your help Mimcc not just here but everywhere you have answered others peoples questions and helped increase my knowledge. This is a great place its just a shame it looks like they are going a bit more comercial. Never mind it is worth it
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
LVL 101

Expert Comment

by:mlmcc
ID: 8033225
Let me check at work.  I know such lists exist but I don't know where they are available.

Doesn't your VB provide a list of values when you type it in?

mlmcc
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 140 total points
ID: 8033589
Iwas close.  Forgot that with Excel you have to include the version.

Depending on the version of Excel you want, use
crEFTExcel50
crEFTExcel50Tabular

crEFTExcel70
crEFTExcel70Tabular

crEFTExcel80
crEFTExcel80Tabular

mlmcc
0
 
LVL 1

Author Comment

by:davoman
ID: 8042319
You are the daddy
cheers my friend just sorry i did not have any more points
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8043321
No problem.  Was fairly easy to find once I got where I had all the resources.

mlmcc
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

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 video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

571 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