Skip to Content
author's profile photo Former Member
Former Member

trying to alter excel format of crystal report exported to excel.

Hi, I am trying to clean up the excel export of a crystal report and am using visual studio 2005 and the CR.net that comes with it, I think version 10.

I have the following code that it runs if the export type is excel and I was just trying to make sure it is working. It does not seem to be making any difference in the exported excel file.

I am using office 2007.

private ReportDocument document;

ExcelFormatOptions excelformat = new ExcelFormatOptions();

excelformat.ExcelUseConstantColumnWidth = true ;

excelformat.ExcelConstantColumnWidth = 20;

excelformat.ExcelTabHasColumnHeadings = false;

excelformat.LastPageNumber = 2;

excelformat.FirstPageNumber = 3;

excelformat.UsePageRange = true;

document.ExportOptions.ExportFormatOptions = excelformat;

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 03:49 PM

    Hi, Paul;

    Try changing your code a bit.

    Change the line:

    document.ExportOptions.ExportFormatOptions = excelformat

    to:

    ExportOptions.ExportFormatOptions = excelformat

    document.Export (ExportOptions)

    Then try different options for the formatting to see if they are really changes.

    Regards,

    Jonathan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi, Paul;

      Here is the complete block of sample code:

      Dim rep As New CrystalReport1

      Dim expOptions As New ExportOptions

      Dim expdest As New DiskFileDestinationOptions

      Dim expformat As New ExcelDataOnlyFormatOptions

      '----


      expdest.DiskFileName = "c:\ExportedExcel.xls"

      '----


      expformat.ExcelUseConstantColumnWidth = True

      expformat.ExcelAreaType = AreaSectionKind.WholeReport

      expformat.ExcelConstantColumnWidth = 60

      expformat.ExcelUseConstantColumnWidth = True

      expformat.ExportPageHeaderAndPageFooter = True

      '----


      expOptions.ExportDestinationType =

      ExportDestinationType.DiskFile

      expOptions.ExportDestinationOptions = expdest

      expOptions.ExportFormatOptions = expformat

      expOptions.ExportFormatType = ExportFormatType.ExcelRecord

      '----


      rep.Export(expOptions)

      Regards,

      Jonathan

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 04:57 PM

    thanks for the quick response, I am using C#, I think your example is in VB. I think my code is the equivalent in C# but I will take a closer look at the code you provided. Assuming the code is correct wondering if there is anything else that could cause it from not working?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 05:14 PM

    Hi I tried the settings in the example but still did not see any changes. I noticed that in my code the export type is Excel where in the example it is ExcelRecord, although do not think this would make a difference. Will take another look at my code.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.