• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1141
  • Last Modified:

After exporting to Excel the Alignment / Formating is messed up!

Hi There,

I am using Crystal Reports 9 and VB 6 for exporting it to Excel. The export works fine but the final exported xls sheet is not what I expect. all the columns have equal width and the allignment is all messed up. I even used ruler lines in the designer to help allign the columns vertically but still no use. But when I export it directly through crystal reports, its perfect. with columns widths and allignment are all according to what i have given in the report.

I am using the following code to export please suggest.

                Dim Appl As New CRAXDRT.Application
                Dim Rpt  As CRAXDRT.Report

                Rpt.ExportOptions.FormatType = crEFTExcel97
                Rpt.ExportOptions.ExcelUseConstantColumnWidth = False  
                Rpt.ExportOptions.DestinationType = crEDTDiskFile
                Rpt.Export False

for the statement "Rpt.ExportOptions.ExcelUseConstantColumnWidth = False" even if I give True here it still gives the same output. I even tried Different FormatTypes like Excel80 etc. But no use.

Thanks,
Faisal.
0
faisalee
Asked:
faisalee
  • 2
  • 2
1 Solution
 
mlmccCommented:
This is an undocumented "feature" of Crystal.  Crystal attempts to recreate the report in its exact format in Excel.  Unfortunately Excel is probably using different fonts so things end up not aligning as expected.  Also they don't fit into single columns so manipulation is difficult.

Look at
http://www.experts-exchange.com/Databases/Crystal_Reports/Q_20946957.html#10780149

I believe CR9 has the ability to export the data only which might do what you want.  

Because of this problem (I use CR8) and the fact that all my users want a "true" spreadsheet when they export a report I wrote code to do the export using the recordset rather than allow Crystal to do the export.

mlmcc

0
 
faisaleeAuthor Commented:
Hi mlmcc,

Thanks for the answer... I also thought the same As you said that, "its an undocumented issue in Crystal reports", but still the url to the PDF contains some great info about exporting to Excel :-) Thanks anyways.

Looks like I will have to write code to export directly to excel instead of using crystal reports. The only problem is that we have already finished the 500 + reports to do the this job :-(

Oh well... Maybe we can extend the project a little bit or we can convince the clients to live with the generated XLS files as they are ;-)

Thanks any ways for the prompt reply.

Faisal.
0
 
mlmccCommented:
I have code already written that uses the query the report is based on to do the export.  I can make it available if you wish.

mlmcc
0
 
faisaleeAuthor Commented:
Oh great... that will solve half of the problem :-) you can send it to me at <email address removed by mlmcc PE>

Thanks for the great help.

Faisal.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

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

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