cancel
Showing results for 
Search instead for 
Did you mean: 

Export to Excel options in Crystal 2011

Former Member
0 Kudos

Hi, we recently upgraded to Crystal 2011 from Crystal XI...  Our new product uses the CrystalDecisions.Windows.Forms.CrystalReportViewer to display the final report and allow users to export out the report to other formats such as Excel.  In the old version, we used the CrystalActiveXReportViewer to achieve the same functionality.  The problem is that the old version, when exporting to Excel, gave more formatting options such as "Export page header and page footers", but the new version doesn't seem to have any of those options and our customers had gotten used to having that flexibility.  Is there any way to access that additional functionality in 2011?

Thanks,

Kent

Accepted Solutions (1)

Accepted Solutions (1)

raghavendra_hullur
Active Contributor
0 Kudos

Hi,

The options you said "Export Page Header and Page Footer" and other options are there under "Microsoft Excel (97-2003)Data-Only" format and I think it was the same in XI R2 too.

Microsoft Excel(97-2003) format don't have those options

Thanks,

Raghavendra

Former Member
0 Kudos

Hi,

when comparing exports types for cr2008 and cr2011, the only some new ones here :-

Crystal Reports read only(RPTR)

Microsoft Excel (97-2003) Data-only

Microsoft Excel workbook Data only.

Have a look INTO this:

Thanks,

DJ

0 Kudos

Moved to .NET SDK forums

Need to know what SDK you are using?

Windows or WEB app?

And exporting from the Viewer or through your own export button and manually setting those options?

Try searching, there are likely KBA's and samples on how to.

Don

Former Member
0 Kudos

Hi,

Thanks for the reply.  The options for export to Excel provided in the old version does not seem to appear in the new version of the CrystalDecisions.Windows.Forms.CrystalReportViewer.  When exporting in Crystal XI, the standard file save dialog allowed us to choose "Microsoft Excel 97-2000 (xls)" and then when you pressed okay, it would display a secondary dialog allowing the user further options for formating the excel report. We want to be able to format the rexported excel file to have header, footer, page break, etc....  Please see attached screenshot for export differences between Crystal XI and Crystal 2011 options.

Thank you,

Kent

DellSC
Active Contributor
0 Kudos

The bottom image shows you trying to export to .rpt, not to Excel.  I don't have CR 2011 installed, but in CR 2013, it looks like this:

-Dell

Former Member
0 Kudos

Hi,

Thanks for your reply.

Our current product is a Windows application, and we are using the CrystalDecisions.Windows.Forms.CrystalReportViewer to show the report and to export to Excel by seting the ShowExportButton to true.

Thank you,

Kent

Former Member
0 Kudos

Hi,

Thanks,

The buttom image is not match what we want to do, we acturally want to export to Excell, sorry for the confusion. We use CrystalDecisions.Windows.Forms.CrystalReportViewer to view the report. We try to export to Excel by setting the ShowExportButton to true. But when we click on the export button, then standard  file save dialog comes up, not the Export dialog you gave in your image. The dialogs shown in your image are the dialogs we want to show to the user. If these dialogs come up with the CR2013, I think they should show in CR 2011 too. How do you make these dialogs showing up in the CrystalDecisions.Windows.Forms.CrystalReportViewer? Your help will be greately appreciated.

Thank you again.

Kent

Former Member
0 Kudos

Hi,

See this:

Some of valuable suggestions are helpful to you ..Please check the above thread

Thanks,

DJ

0 Kudos

Hi Kent,

There are 2 ways to handle this.

#1. Open the report in CR Designer and click on the Export Menu option:

Select Excel and set the default properties you want to use then you get that UI:

In code you can now get those SavedExport options:

NOTE: not all formats can be saved:

private void getSavedExportOptions(CrystalDecisions.CrystalReports.Engine.ReportDocument rpt)

{

    Array valArray1 = Enum.GetValues(typeof(CrReportExportFormatEnum));

    foreach (object obj in valArray1)

    {

        lstExportFormatType.Items.Add(obj);

    }

    CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions RASexportOpts = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions();

        CrystalDecisions.ReportAppServer.ReportDefModel.DataOnlyExcelExportFormatOptions RasExcelDataOnlyExpOpts = new DataOnlyExcelExportFormatOptions();

    CrystalDecisions.ReportAppServer.ReportDefModel.ExcelExportFormatOptions RasXLSExpOpts = new ExcelExportFormatOptions();

    //CrystalDecisions.ReportAppServer.ReportDefModel.CrReportExportFormatEnum.crReportExportFormatPaginatedTxt

    string textBox1 = String.Empty;

    string MyObjectType = ReportObjectComboBox1.SelectedItem.ToString();

    btnReportObjects.Text = "";

    foreach (CrystalDecisions.ReportAppServer.ReportDefModel.CrReportExportFormatEnum SavedExpType in valArray1)

    {

        switch (SavedExpType.ToString())

        {

case "crReportExportFormatMSExcel":

    try

    {

        RasXLSExpOpts = rptClientDoc.get_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatMSExcel);

    }

    catch (Exception ex)

    {

        textBox1 += "MSExcel or Record Style - Not saved\n 'End' \n\n";

        break;

    }

    textBox1 += "\nMSExcel or Record Style : \n";

    if (RasXLSExpOpts != null)

    {

        textBox1 += "BaseAreaGroupNumber:       " + RasXLSExpOpts.BaseAreaGroupNumber.ToString() + "\n";

        textBox1 += "BaseAreaType:              " + RasXLSExpOpts.BaseAreaType.ToString() + "\n";

        textBox1 += "FormulaExportPageAreaType: " + RasXLSExpOpts.ExportPageAreaPairType.ToString() + "\n";

        textBox1 += "ExportPageBreaks:          " + RasXLSExpOpts.ExportPageBreaks.ToString() + "\n";

        textBox1 += "ConstantColWidth:          " + RasXLSExpOpts.ConstantColWidth.ToString() + "\n";

        textBox1 += "ConvertDatesToStrings:     " + RasXLSExpOpts.ConvertDatesToStrings.ToString() + "\n";

        textBox1 += "StartPageNumber:           " + RasXLSExpOpts.StartPageNumber.ToString() + "\n";

        textBox1 += "EndPageNumber:             " + RasXLSExpOpts.EndPageNumber.ToString() + "\n";

        textBox1 += "ExportPageBreaks:          " + RasXLSExpOpts.ExportPageBreaks.ToString() + "\n";

        textBox1 += "MRelativeObjectPosition:   " + RasXLSExpOpts.MaintainRelativeObjectPosition.ToString() + "\n";

        textBox1 += "ShowGridlines:             " + RasXLSExpOpts.ShowGridlines.ToString() + "\n";

        textBox1 += "UseConstantColWidth:       " + RasXLSExpOpts.UseConstantColWidth.ToString() + "\n";

    }

    btnReportObjects.Text += textBox1;

    btnReportObjects.AppendText(" 'End' \n\n");

    textBox1 = "";

    break;

If this doesn't work for you then you can replace the viewers export button with your own and handle the values yourself with your own UI.

See this KBA with a sample app attached:

1765153 - How to customize .NET Viewer Control Export button to manage custom export options and ena...

PS - link will not work for you so search for the number in the upper right corner.

Thanks

Don

Answers (0)