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

Exporting to excel fails for column bound to datatype char

2 Answers 39 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tord
Top achievements
Rank 1
Tord asked on 30 Apr 2013, 07:40 PM
Hi.

I have an object with a property of type char like this:

public class DummyModel
   {
       public string Stringtest { get; set; }
       public char Chartest { get; set; }
   }


When binding a grid to a list of this objects the values in the char property are displayed correctly in a grid column.

But when I export the grid using ExcelML the column in Excel comes up empty.
Doesn't ExcelML support exporting the char datatype?

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 03 May 2013, 01:34 PM
Hello,

Due to Easter observations, we are currently operating with limited resources until May 7th. We will get back to you as soon as possible. Please excuse us for the introduced inconvenience.
 
Regards,
Stefan
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.

0
Stefan
Telerik team
answered on 22 May 2013, 11:12 AM
Hello Tord,

Please excuse me for the delayed reply. I managed to miss this thread somehow.

To answer your question, the char data type is not recognized by Excel and this is why it is not displayed. To hand this case, you can use the ExcelCellFormatting event of the exporter, where you can convert the char to string in the exported document:
void radButton1_Click(object sender, EventArgs e)
{
    ExportToExcelML exporter = new ExportToExcelML(this.radGridView1);
    string fileName = "C:\\ExportedData123.xls";
    exporter.ExcelCellFormatting += exporter_ExcelCellFormatting;
    exporter.RunExport(fileName);
    Process.Start("C:\\ExportedData123.xls");
}
 
void exporter_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e)
{
    e.ExcelCellElement.Data.DataItem = Convert.ToString(e.GridCellInfo.Value);
}

I hope that you find this useful. Once again, excuse me for the delay.

Regards,
Stefan
Telerik
RadChart for WinForms is obsolete. Now what?
Tags
GridView
Asked by
Tord
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or