Skip to Content
Former Member
Jan 13, 2009 at 04:10 PM

Export to CSV - "Not enough memory for operation"


Good Morning,

I am in the process of exporting a report which has multiple sub-reports to a CSV file. Upon using the .ExportToDisk() method and passing in the CSV type, I have no problems at all. However, if I try to specify Export Options and use the Export() method it gives me the 'not enough memory for operation' error on export. Any help would be greatly appreciated. Thanks!

//Create Crystal Report & Set DB, Parameters, etc.
        ReportDocument report1 = new ReportDocument();
        String reportPath = "//localhost/hd/reports/"+p+".rpt";
        report1.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Auto;
        report1.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
        report1.SetDatabaseLogon("qt", "qt", "radb", "");
        report1.SetParameterValue("PID", addPID);

        //Pull Currently Logged in User
        string user = Session["username"].ToString();
        //Declare Variables and Get Export Options
        ExportOptions exportOpts = report1.ExportOptions;
        CharacterSeparatedValuesFormatOptions csvFormat = ExportOptions.CreateCharacterSeparatedValuesFormatOptions();
        DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions();
        exportOpts.ExportFormatType = ExportFormatType.CharacterSeparatedValues;

        //Set Export Option to Isolate Report and Group Header rows from data rows
        csvFormat.ReportSectionsOption = CsvExportSectionsOption.ExportIsolated;
        csvFormat.GroupSectionsOption = CsvExportSectionsOption.ExportIsolated;

        //Bind CSV Format Options to the reports Export Options
        exportOpts.ExportFormatOptions = csvFormat;
        exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;

        //Set Export File Name
        string filename = "//localhost//hd//reports//" + p + "-" + user + ".csv";
        diskOpts.DiskFileName = filename;

        //Bind DestinationOptions to the corresponding paramter in Export Options
        exportOpts.ExportDestinationOptions = diskOpts;

        //report1.ExportToDisk(ExportFormatType.CharacterSeparatedValues, "//localhost//hd//reports//"+p+"-"+user+".csv");