This is a migrated thread and some comments may be shown as answers.

exporttocsv with option EncloseDataWithQuotes in winforms

1 Answer 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sree
Top achievements
Rank 1
Sree asked on 10 Jan 2013, 08:47 AM
Hello Team

I got a strange problem with winform  gridview  when exported to .csv , it exported the gridview data to .csv with enclosed quotes,

        "1"     "12.01" "22.01" "33.768"        "2.12344"       "5655.34"
        "1"     "13.01" "23.01" "34.768"        "2.12344"       "5656.34"
        "1"     "14.01" "24.01" "35.768"        "2.12344"       "5657.34"
        "1"     "15.01" "25.01" "36.768"        "2.12344"       "5658.34" 


 i observed that in ASP.NET AJAX gridview there is an option called EncloseDataWithQuotes =True/False, with this we can eliminate the enclosed quotes in the csv

if winforms gridview also have the same property please tell me where i need to set it???, i checked in the below link, but there is no option to set

http://www.telerik.com/help/winforms/gridview-exporting-data-export-to-csv.html

due to the quotes in the data, i couldnt import to mySql database, please suggest the way to eliminate the quotes in .csv file
here is my code to export to .csv

                 ExportToCSV exporter = new ExportToCSV(this.radGridView1);              
                 string fileName = "C:\\ExportedData.csv";              
                exporter.RunExport(fileName);



1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 14 Jan 2013, 02:46 PM
Hi Lakshmi,

Thank you for writing.

Currently, we do not support a property EncloseDataWithQuotes. A comma-separated values (CSV) file stores tabular data (numbers and text) in plain-text format. The data must be processed before they are being displayed. CSV is a delimited text file that uses a comma to separate values. You could read more about the CSV format here: http://en.wikipedia.org/wiki/Comma-separated_values.

As to the problem at hand, I have added this as a feature request. You can track the status of the item in our Public Issue Trucking System at the following location: http://www.telerik.com/support/pits.aspx#/public/winforms/13980.

I have updated your Telerik Points for this request.

Here is a sample method which removes the quotes from the CSV file:
string[] text = System.IO.File.ReadAllLines("C:\\ExportedData.csv");
for (int i = 0; i < text.Length; i++)
{
    text[i] = text[i].Replace("\"", "");
}
System.IO.File.WriteAllLines("C:\\ExportedData.csv", text);

I hope this helps.

Regards,
Plamen
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
GridView
Asked by
Sree
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or