Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to excel from crystal reports 9

Status
Not open for further replies.

Rob2k2

Technical User
Oct 14, 2002
36
0
0
GB
I am trying to export a report to excel(csv) format from crystal reports 9 in VB6. Everything is working fine, but i need to be able to change the colum widths of the columns to a custom value.

This can be done, if you show the users the export dialog box below and allow them to specify a colum width.

However, i want to be able to do this through VB code, I know it is possible but cant seem to be able to achieve it.

Any ideas?
 
Hi

Using RDC you can acheive this. Set the ExportOptions object's ExcelUseConstantColumnWidth , ExcelConstantColumnWidth you can acheive this. Please see the sample code below.

Dim objRptOptions As ExportOptions
Dim objCrysApp As New CRAXDRT.Application
Dim objCrysRep As Report


Set objCrysRep = objCrysApp.OpenReport("C:\Report1.rpt", 1)
objCrysRep.MorePrintEngineErrorMessages = False
objCrysRep.EnableParameterPrompting = False
objCrysRep.DiscardSavedData




Set objRptOptions = objCrysRep.ExportOptions
With objRptOptions
.DestinationType = 1
.FormatType = crEFTExcel97 '&H1F '&H20
.ExcelUseConstantColumnWidth = True
.ExcelUseTabularFormat = True
.ExcelTabHasColumnHeadings = True
.ExcelConstantColumnWidth = 10000
.DiskFileName = "C:\TestExcel1.xls"

End With
objCrysRep.DisplayProgressDialog = False

objCrysRep.Export False

Hope this helps

Regards
Krishna Kumar
 
Thanks a lot, all I needed however was the:-

.ExcelConstantColumnWidth = 10000

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top