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

Export To CSV error

4 Answers 68 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Deepak
Top achievements
Rank 1
Deepak asked on 12 Apr 2011, 01:10 PM
When one of the values of a cell is "Department Stores", it errors out. Initially I thought it might be the space, but other values with space work fine. I have a cellformating event handled, but it does not get there. In other words, it errors out before the event fires

Here is the stack trace

System.NullReferenceException: Object reference not set to an instance of an object.

   at Telerik.WinControls.UI.Export.CSV.CellElement.EscapeQuotesInValue()

   at Telerik.WinControls.UI.Export.CSV.CellElement.RenderChildElements(StringBuilder sb)

   at Telerik.WinControls.UI.Export.CSV.ElementBase.Render(StringBuilder sb)

   at Telerik.WinControls.UI.Export.CSV.RowElement.RenderChildElements(StringBuilder sb)

   at Telerik.WinControls.UI.Export.CSV.ElementBase.Render(StringBuilder sb)

   at Telerik.WinControls.UI.Export.ExportToCSV.FileWriteElement(FileStream fileStream, ElementBase csvElement, Int32 cutLastSymbols)

   at Telerik.WinControls.UI.Export.ExportToCSV.AddCSVRow(GridViewRowInfo gridRowInfo, FileStream fileStream, TableElement csvTableElement)

   at Telerik.WinControls.UI.Export.ExportToCSV.RunExport(String fileName)




Thanks
Deepak

4 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 12 Apr 2011, 02:00 PM
Hi Deepak,

I haven't been avble to replicate your error with the latest version. Please can you try the following in a new project.

    public Form1()
    {
        InitializeComponent();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
          
        this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        this.radGridView1.Columns.Add(new GridViewTextBoxColumn("A"));
        this.radGridView1.Columns.Add(new GridViewTextBoxColumn("B"));
        this.radGridView1.Rows.Add("A1", @"""Department Stores""");
        this.radGridView1.Rows.Add("A2", @"""Department Stores""");
    }
    private ExportToCSV exporter;
    private void radButton1_Click(object sender, EventArgs e)
    {
        exporter = new ExportToCSV(radGridView1);
        // replace with your own filepath
        exporter.RunExport(@"C:\Users\Richard\Documents\MyCSV.csv");
    }
}

If this works for you, then please can you post a small sample to replicate the issue.
Thanks
Richard
0
Deepak
Top achievements
Rank 1
answered on 14 Apr 2011, 11:22 AM
Hello Richard,
 Sorry for the late reply. As I found out it had nothing to do with "Department Stores", but along with the data that contained "Department Stores", there was an extra column which was causing this error.

Thanks
Deepak
0
Martin Vasilev
Telerik team
answered on 15 Apr 2011, 12:06 PM
Hello Deepak,

Could you please send us some sample code, which demonstrates your scenario. I am also unable to reproduce the exception on my side and I need additional details to investigate it further.

I look forward to your reply.

All the best,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Deepak
Top achievements
Rank 1
answered on 15 Apr 2011, 01:21 PM
Hello Martin/Richard,
 Sorry if I wasnt clear, I have fixed it by removing the erenous column. I will try to post some sample code...

Thanks
Deepak
Tags
GridView
Asked by
Deepak
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Deepak
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or