Hi
When I export a rad grid to an excel the integer and decimal values get converted to string.User has to select all the columns and convert them to integer. Is there any way while exporting they get stored as integer?
When I export a rad grid to an excel the integer and decimal values get converted to string.User has to select all the columns and convert them to integer. Is there any way while exporting they get stored as integer?
public
static
void
ExportingGrid(RadGridView grid,
string
exportFormat)
{
try
{
string
extension =
string
.Empty;
ExportFormat format = ExportFormat.Html;
switch
(exportFormat)
{
case
"Excel"
: extension =
"xls"
;
format = ExportFormat.ExcelML;
break
;
case
"Csv"
: extension =
"csv"
;
format = ExportFormat.Csv;
break
;
}
SaveFileDialog dialog =
new
SaveFileDialog();
dialog.DefaultExt = extension;
dialog.Filter = String.Format(
"{1} files (*.{0})|*.{0}|All files (*.*)|*.*"
, extension, exportFormat);
dialog.FilterIndex = 1;
if
(dialog.ShowDialog() ==
true
)
{
using
(Stream stream = dialog.OpenFile())
{
GridViewExportOptions exportOptions =
new
GridViewExportOptions();
exportOptions.Format = format;
exportOptions.ShowColumnFooters =
true
;
exportOptions.ShowColumnHeaders =
true
;
exportOptions.ShowGroupFooters =
true
;
grid.Export(stream, exportOptions);
}
}
}
catch
(Exception ex)
{
throw
ex;
}
}
9 Answers, 1 is accepted
0
Hello Sonu,
One of the approaches is to export to Html format. Then you should not have any troubles.
Attached is how to achieve your goal with the ExcelML format.
Greetings,
Veselin Vasilev
the Telerik team
One of the approaches is to export to Html format. Then you should not have any troubles.
Attached is how to achieve your goal with the ExcelML format.
Greetings,
Veselin 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
Nikhil Thaker
Top achievements
Rank 1
answered on 21 Dec 2010, 09:22 AM
Hi,
While using the code given in the first post, when I am opening the exported excel file it always shows the warning message as shown in attached screen shot (Warning Message 1.png)..
And it prompts when I try to save the file as in another attached screenshot (Warning Message 2.png)..
So how to solve these issues.
Thanks in advance.
While using the code given in the first post, when I am opening the exported excel file it always shows the warning message as shown in attached screen shot (Warning Message 1.png)..
And it prompts when I try to save the file as in another attached screenshot (Warning Message 2.png)..
So how to solve these issues.
Thanks in advance.
0
Hi Nikhil Thaker,
This help topic explains why this happens. You can export to ExcelML format (in an .xml file) and then the Excel will not warn when it tries to open it.
Best wishes,
Veselin Vasilev
the Telerik team
This help topic explains why this happens. You can export to ExcelML format (in an .xml file) and then the Excel will not warn when it tries to open it.
Best wishes,
Veselin Vasilev
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Nikhil Thaker
Top achievements
Rank 1
answered on 21 Dec 2010, 09:51 AM
Thanks for quick reply,
But even on using ExcelML format .. still Excel warns the same..while opening and saving the file..
Please suggest some other solution or work around if possible.
But even on using ExcelML format .. still Excel warns the same..while opening and saving the file..
Please suggest some other solution or work around if possible.
0
Hello Nikhil Thaker,
Can you please try to export to ExcelML on our online demo. I have just tested it and the Excel (2007) did not complain.
All the best,
Veselin Vasilev
the Telerik team
Can you please try to export to ExcelML on our online demo. I have just tested it and the Excel (2007) did not complain.
All the best,
Veselin Vasilev
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
ronald
Top achievements
Rank 1
answered on 24 Jan 2011, 06:21 AM
I'm having the same issue.. compatibility warning message.
I'm using the exact same code as in this link:
http://www.telerik.com/help/wpf/gridview-export.html
also, I changed the format to ExportFormat.ExcelML but no luck..
is this a bug in telerik radgridview?
I'm using the exact same code as in this link:
http://www.telerik.com/help/wpf/gridview-export.html
also, I changed the format to ExportFormat.ExcelML but no luck..
is this a bug in telerik radgridview?
0
Hello,
Vlad
the Telerik team
If you save the output from ExcelML export with xml extension you will not get such problems.
Kind regards,Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
ronald
Top achievements
Rank 1
answered on 24 Jan 2011, 08:36 AM
but i need to use the .xls extension and not .xml... any ideas?
thanks
thanks
0
Hi,
Vlad
the Telerik team
MS Excel will open it even with XML extension since you will have ExcelML data.
Best wishes,Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>