SAP Knowledge Base Article - Public

2504603 - Setting page length to 0 generates an error when exporting to Text format in Crystal Reports for Visual Studio

Symptom

Using below code when setting page length to zero, same as what is available in CR Designer Report Export Options for Text format, unpaginated, Crystal Reports for Visual Studio  generates an error:

ERROR: The number of lines per page must be greater than zero.

Environment

Crystal Reports for Visual Studio SP 20

Reproducing the Issue

Please provide step-by-step instructions on how to reproduce your issue:

if (ExportTypeSelected == "crReportExportFormatText")
#region TXT
{
    // This works do not alter
    // 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)) + "txt";
    try
    {
        if (File.Exists(outputFileName))
        {
            File.Delete(outputFileName);
        }

        //CrystalDecisions.ReportAppServer.ReportDefModel. RasRTFExpOpts = new RTFWordExportFormatOptions();
        CrystalDecisions.ReportAppServer.ReportDefModel.TextExportFormatOptions RastxtExpOpts = new TextExportFormatOptions();

        try
        {
            RastxtExpOpts = rptClientDoc.get_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatText);
        }
        catch (Exception ex)
        {
            btnSQLStatement.Text = "ERROR: " + ex.Message;
            //return;
        }

        // Set them now:
        RastxtExpOpts.CharactersPerInch = 20;
        RastxtExpOpts.LinesPerPage = 0; // this line causes the error

        // Save the udpated info
        if (RastxtExpOpts != null)
            rptClientDoc.set_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatText, RastxtExpOpts);

        CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions exportOpts1 = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions();
        exportOpts1.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatText;
        exportOpts1.FormatOptions = RastxtExpOpts;

        // And Export
        rptClientDoc.PrintOutputController.ExportEx(exportOpts1).Save(outputFileName, true);
        MessageBox.Show("Export to Txt Completed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

    }
    catch (Exception ex)
    {
        btnSQLStatement.Text = "ERROR: " + ex.Message;
        return;
    }
}
#endregion TXT

Resolution

This issue has been reported to R&D to determine if this is by design or a change is required.

Keywords

cr for vs, page length, text output , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio