cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Crystal Reports For VS v13.0.17.2096 - Default Export Filename

Former Member
0 Kudos

I have just bought SAP Crystal Reports 2016 and I am using Microsoft Visual Studio 2015 with Crystal Reports for VS v13.0.17.2096 installed. I have built a webpage that contains the CrystalReportViewer control to display my report. My problem is when the user clicks Export from the toolbar the filename of the PDF is always defaulted "crViewer.pdf" which is the ID of the CrystalReportViewer control. I want to default the filename using a date and time stamp or some other known unique identifier, so the client can easily save them to their network folder.

I have tried using the following code:-

crViewer.ID = "Report_" + Format(Now, "yyyyMMdd_HHmm")

But this makes the control unstable. How do I default the export filename using the Export button from the Crystal Reports toolbar?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Are you using Sessions and PostBack, it's a MUST to keep the viewer in Session and using POSTBACK is the only way?

This works for me, a PITY you did not post all of your code:

protected void Page_Init(object sender, EventArgs e)

{

    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

    rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

      

    CrystalDecisions.CrystalReports.Engine.Database crDatabase;

    CrystalDecisions.CrystalReports.Engine.Tables crTables;

    CrystalDecisions.Shared.TableLogOnInfo tblogoninfo;

    CrystalDecisions.Shared.ConnectionInfo cninfo;

    string url = "/inetpub/wwwroot/WebSite7VS2015/Reports/test.rpt";

    rd.FileName = url;

    #region Session

    if (Session["rd"] == null)

    {

        try

        {

        rd.Load(url, OpenReportMethod.OpenReportByTempCopy);
        Session.Add("rd", rd);
        }

        finally

        {

            // open the database connection

            //myConnection.Close();

        }

    }

    #endregion Session

    CrystalReportViewer1.Height = 300;

    CrystalReportViewer1.Width = 300;

    CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;

    // set up the format export types:

    int myFOpts = (int)(

        CrystalDecisions.Shared.ViewerExportFormats.RptFormat |

        CrystalDecisions.Shared.ViewerExportFormats.PdfFormat |

        CrystalDecisions.Shared.ViewerExportFormats.RptrFormat |

        //CrystalDecisions.Shared.ViewerExportFormats.XLSXFormat |

        //CrystalDecisions.Shared.ViewerExportFormats.CsvFormat |

        //CrystalDecisions.Shared.ViewerExportFormats.EditableRtfFormat |

        //CrystalDecisions.Shared.ViewerExportFormats.ExcelRecordFormat |

        //CrystalDecisions.Shared.ViewerExportFormats.RtfFormat |

        //CrystalDecisions.Shared.ViewerExportFormats.WordFormat |

        CrystalDecisions.Shared.ViewerExportFormats.XmlFormat |

        CrystalDecisions.Shared.ViewerExportFormats.ExcelFormat |

        //CrystalDecisions.Shared.ViewerExportFormats.AllFormats |

        CrystalDecisions.Shared.ViewerExportFormats.ExcelRecordFormat);

    //CrystalDecisions.Shared.ViewerExportFormats.NoFormat); // no exports allowed

    //int myFOpts = (int)(CrystalDecisions.Shared.ViewerExportFormats.AllFormats);

    CrystalReportViewer1.AllowedExportFormats = myFOpts;

    CrystalReportViewer1.ID = "ReportUsageDetailByArea";

    CrystalReportViewer1.ReportSource = Session["rd"];

    CrystalReportViewer1.EnableParameterPrompt = true;

    CrystalReportViewer1.HasToggleParameterPanelButton = true;

}

Sales will sell you a single case for support, just ask them. If whomever you were talking to did not know tell them to go ask, a single case is available WITHOUT a support contract.

Good luck

Don

Answers (1)

Answers (1)

0 Kudos

Hi Nicholas,

Two ways to do this. Set the Title name in the Report Summary info or if using the Engine to open the report you can do this in code:

// this gets the report name and sets the export name to be the same less the extension

string outputFileName = "";

string MyRptName = rpt.FileName.ToString();

outputFileName = MyRptName.Substring(9, rpt.FileName.Length - 9);

outputFileName = outputFileName.Substring(0, (outputFileName.Length - 3)) + "pdf";

try

{

    if (File.Exists(outputFileName))

    {

        File.Delete(outputFileName);

    }

....

Export to disk

Don

Former Member
0 Kudos

I have already tried setting the Title (as follows) but this fails to default the export filename.

oDoc.SummaryInfo.ReportTitle = strService + "_" + Format(Now, "yyyyMMdd_HHmm")

Your second solution/example eludes me, because your variable outputFileName is not setting to any crystal report object to default the export filename. I need to able to default the Export filename on the Crystal Reports viewer control or the report object itself. So that when the user clicks the standard Export button on the Crystal Report Web toolbar it comes up with the defauilt filename and not the class name of the Crystal Report viewer control.

0 Kudos

Hi Nicholas,

Ah yes, sorry. My code is for a Desktop app.

I get the same thing, check to see if I or Dan have any examples of how to or if it can be done.

You may not be able to using the default Export button and may have to create your own export button.

Don

Former Member
0 Kudos

Thanks for your reply, but rewriting the Crystal Reports toolbar on a new product just released seems rather drastic. I have recently discovered that SAP themselves do not provide any technical support for Crystal Report 2016 even on a recently purchased product. I can't even purchased a support incident for the product. I think this is a poor show for a company.

Do you know of a free link to report software bugs (without having a special paid "S" user account). I simply want to report this bug so that they can consider it in the next release update.

0 Kudos

Yes you can purchase a single Incident case, it's on the Overview Tab, right side

Go there, bottom right is link to generate a request:

https://www.sapstore.com/solutions/99013/SAP-Crystal-Reports-2013?url_id=text-us-store-scn-crystalre...

And too bad you did not search first:

1486910 - How to change the file name while exporting using the Crystal Reports DHTML viewer for VS .NET

CrystalReportViewer1.ID = "ReportUsageDetailByArea";

CrystalReportViewer1.ReportSource = Session["rd"];

Not a bug, you just needed to search more.

Don

Former Member
0 Kudos

Don, as I said in my original post, I have tried setting property "ID" as follows:-

crViewer.ID = "Report_" + Format(Now, "yyyyMMdd_HHmm")

PROBLEM WITH THIS:- Once you change the ID to a different name, the Crystal Report Viewer no longer works and the toolbar crashes. Why? Because the toolbar (which is written in JAVA) can no longer reference the ID of the Crystal Report Viewer control because you have changed it at run-time!

A pity you did not read my original post. Yes it is a bug because the filename should NEVER be taken from an internal control class name! It should be take from the Report Title or something similar. The fact I can't change the ID without crashing the Crystal Reports Viewer in 2016, and the fact they are using the controls class name for the filename, I see this as a BUG!

On the Support Incident, this only applies to server products ONLY! I phoned SAP and they said you must buy a server product to create a SAP ONE account. Unless you have a SAP ONE account you can't get support period! Buy an incident would be useless without a SAP ONE account, which is only obtainable by buying a server product!