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

Export to excel problem?

1 Answer 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Maksut
Top achievements
Rank 1
Maksut asked on 29 Jan 2013, 08:47 AM
Hi, 

Hi,

I need to export excel. 

I am using   RadGrid1.MasterTableView.ExportToExcel();

Everything is ok. I can export. But one of my columns is 25-26 digit. For example

My grid is;

Barcode(datatype:text)--------------code(datetype:text)
10105570021112201100001------125
10105570072610201100001------110          
10105570020112201100001------165


When I push the button. My excel is coming this type. 

Barcode----------------Code       
1.01056E+22 ---------125 
1.01056E+22----------110
1.01056E+22-----------165


After export. İf I change "format cells" in the excel. My barcode is changing this type

10105570021112200000000
 10105570072610200000000
 10105570020112200000000

How can ı solve? 

p.s.: Sorry my english

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 06 Feb 2013, 04:53 PM
Hello Maksut,

The number precision in Excel is 15 digits and the rest of them are represented as zeroes. You could read more about the limitations of Excel in the following help topic. A possible solution is to format the number as text. Check out the following code snippet:
protected void RadGrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
    if (e.FormattedColumn.UniqueName == "Barcode")
    {
        e.Cell.Style["mso-number-format"] = @"\@";
    }
}

More about number formats could be found at the following help topic.

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Maksut
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or