Date Filtered Crystal Reports Export (C# Mysql)

Asked

Viewed 58 times

1

I have a Crystal Report object that is bringing the records of a View from a Mysql database. I need these records to be exported to a CSV file and I got this with the following code:

private void btnExportarCSV_Click(object sender, EventArgs e)
{
        string fileName = DateTime.Today.ToString("yyyyMMdd") + ".csv";
        fileName = Config.pathFiles + "\\" + fileName;
        Reports.NotaFiscal_CSVReport cr = new Reports.NotaFiscal_CSVReport();

        DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions();
        diskOpts.DiskFileName = fileName;

        CharacterSeparatedValuesFormatOptions csvFO = ExportOptions.CreateCharacterSeparatedValuesFormatOptions();
        csvFO.ReportSectionsOption = CsvExportSectionsOption.ExportIsolated;
        csvFO.ExportMode = CsvExportMode.Standard;
        csvFO.SeparatorText = ";";
        csvFO.Delimiter = "";

        ExportOptions exportOpts = new ExportOptions();
        exportOpts.ExportFormatType = ExportFormatType.CharacterSeparatedValues;
        exportOpts.ExportFormatOptions = csvFO;
        exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
        exportOpts.ExportDestinationOptions = diskOpts;

        cr.Export(exportOpts);

}

The problem is that there’s a field in this view that’s a date. And I need the report to export only records whose date is in a specified range. I tried to do this in various ways, with parameters, formulas... but without success.

Does anyone know the right way to do this? Recalling that the report is linked to a view, the report dataset is not set in the code...

Thanks!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.