?
Solved

Exporting to excel using VB and CRviewer

Posted on 2003-02-26
7
Medium Priority
?
1,062 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

762 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