Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 515
  • Last Modified:

Problem when exporting to Excel

I have written a simple .rpt viewer using the Crystal Report Viewer control in VB.net 2003. When reports are exported using the export button on the control, several alignment and spacing errors are present. However, these formatting errors are not present if I view and export a report using the Crystal Reports software that I use to design the reports. I'm pretty sure that the problem lies with my report viewer program not using the proper .dll. How do I tell my program to use a different dll to export files? Thanks.
0
smoothrockb
Asked:
smoothrockb
  • 2
  • 2
1 Solution
 
mlmccCommented:
The problem is not with the dll.  To get a report to export as you want you need to set it up correctly.  Crystal tries to export the report as it is to Excell but Excel coulmns cause trouble.

Look at

http://support.businessobjects.com/communityCS/TechnicalPapers/scr_exportexcel.pdf.asp

mlmcc
0
 
smoothrockbAuthor Commented:
I have seen that article, and I don't think it is any help for me, since my reports export to Excel without problems using Crystal Reports 8.5. When I export a program via the Report Viewer control in my viewer application, there are formatting errors, merged cells, misaligned column headers, etc. Also, the gridlines do not appear in the exported excel file. I would rather not have to redesign a large number of reports if I can avoid it. Is there a way to expand the export options packed in with the CrystalReportViewer control in VB.net to be more consistent with the export options present in Crystal Reports?
0
 
mlmccCommented:
I don't think so since CR.Net is a stripped down version of CR9.

Also Crystal deliberately limited the export options on some of the viewers to encourage use of the RDC.

mlmcc
0
 
smoothrockbAuthor Commented:
I figured out a way to come pretty close to the "data only" export option a la the full Crystal Reports software, using the "Export()" method and adjusting settings that way. In case anyone is interested, my code looked like:

If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
            Dim OpenFile As String
            OpenFile = SaveFileDialog1.FileName

            Report1.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
            Dim fileOptions As New CrystalDecisions.Shared.DiskFileDestinationOptions
            fileOptions.DiskFileName = OpenFile
            Report1.ExportOptions.DestinationOptions = fileOptions
            Report1.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.Excel
            Dim excelOptions As New CrystalDecisions.Shared.ExcelFormatOptions
            excelOptions.ExcelUseConstantColumnWidth = False
            excelOptions.ExcelTabHasColumnHeadings = False
            Report1.ExportOptions.FormatOptions = excelOptions

            Report1.Export()
        End If



0
 
ee_ai_constructCommented:
Question answered by asker or dialog valuable.
Closed, 125 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now