Completed
Last Updated: 27 Mar 2023 06:39 by ADMIN
Release R1 2023 SP1
Mark
Created on: 07 Feb 2023 15:26
Category: UI for WinForms
Type: Bug Report
0
RadGridView: ExportToCSV adds an empty row after the last row with data
When exporting with ExportToCSV, the generated text file contains a blank row after the last data row.
1 comment
ADMIN
Todor
Posted on: 07 Feb 2023 15:56

As a workaround, you can use the following approach. After the export read the exported CSV file, remove the last lew line, and save it back to the file system.

private void radButton1_Click(object sender, EventArgs e)
{
    ExportToCSV exporter = new ExportToCSV(this.radGridView1);
    exporter.RunExport(@"C:\Temp\Temp.csv");

    // Open the CSV text file and remove the new line.
    string text = File.ReadAllText(@"C:\Temp\Temp.csv");
    // Text ends with Environment.NewLine, so we need to trim it.
    text = text.Substring(0, text.Length - Environment.NewLine.Length);
    File.WriteAllText(@"C:\Temp\Temp.csv", text);
}

 

Regards,
Todor Vyagov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.