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

Exporting to Excel - get "The file your are trying to open is a differant format"

21 Answers 371 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 17 Jun 2010, 07:38 PM
Hi..
I'm exporting to excel... it exports fine...
But when I open the file I get an MS Error

THE FILE YOU ARE TRYING TO OPEN TEST.XLS IS IN A DIFFERANT FORMAT THAN SPECIFIED BY THE FILE EXTENSION....

Any ideas?   How I can I get rid of this msg?
thanks again

21 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 18 Jun 2010, 06:25 AM
Hi,

 You get this message since the file is not in the default Excel format (XLSX) - most probably HTML. If you export the grid to ExcelML you will not get this message. 

Regards,
Vlad
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
Jon
Top achievements
Rank 1
answered on 18 Jun 2010, 11:54 AM

The following does not work... I even tried changing the the extension to xlsx
Any ideas... thanks

 

System.Windows.Forms.

SaveFileDialog saveDialog = new System.Windows.Forms.SaveFileDialog();

 

saveDialog.Filter =

"Excel files (*.xls) |*.xls|All files (*.*)|*.*";

 

saveDialog.DefaultExt =

"xls";

 

saveDialog.FilterIndex = 1;

 

if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)

 

{

 

using (Stream stream = saveDialog.OpenFile())

 

{

 

GridViewExportOptions options = new GridViewExportOptions()

 

{

Format =

ExportFormat.ExcelML,

 

ShowColumnHeaders =

true,

 

ShowColumnFooters =

true,

 

ShowGroupFooters =

true,

 

};

grid.Export(stream, options);

}

}

0
Vlad
Telerik team
answered on 18 Jun 2010, 01:25 PM
Hello,

You can check our demo for more info. The file is saved as xml. The example is for Silverlight however the code for WPF is the same.

Best wishes,
Vlad
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
Jon
Top achievements
Rank 1
answered on 19 Jun 2010, 11:27 AM
Hi..
I get the same message running the Silverlight export demo from your site as are my users.
What version of Excel are you opening the file in?
I'm using Office2007
thanks
0
Vlad
Telerik team
answered on 21 Jun 2010, 06:17 AM
Hello,

 You get this with ExcelML exporting?

Best wishes,
Vlad
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
Jon
Top achievements
Rank 1
answered on 21 Jun 2010, 11:20 AM
No..
It exports but I get the message on 5 differant PC.. even when running your SL demo from the web.
0
Vlad
Telerik team
answered on 21 Jun 2010, 12:17 PM
Hi,

 Can you tell me what is the extension of the exported file from our demo?

Regards,
Vlad
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
Jon
Top achievements
Rank 1
answered on 21 Jun 2010, 01:52 PM

Hi..

It defaults to .XLS…        

Just tried it on a vista machine… same issue

thanks

0
Vlad
Telerik team
answered on 21 Jun 2010, 02:15 PM
Hi,

You have not selected ExcelML from the combo. Please try again our demo and check the code for more info.

I've attached a screenshot.

Greetings,
Vlad
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
Jon
Top achievements
Rank 1
answered on 21 Jun 2010, 02:28 PM
OK.. I see now...
What's the purpose of XLS... if it doesn't work and you have to use XML?
thanks
0
Wagner
Top achievements
Rank 1
answered on 05 Jul 2010, 05:23 PM
Hi,

I have the same issue when trying to open a .xls file exported by the RadGridView.  Is there a way to avoid this warning message?

Here are the export options I'm using:

                                    new GridViewExportOptions()  
                                    {  
                                        Format = ExportFormat.ExcelML,  
                                        ShowColumnHeaders = true,  
                                        ShowColumnFooters = true,  
                                        ShowGroupFooters = false,  
                                    });  
 

Thanks in advance,

Wagner
0
Yavor Georgiev
Telerik team
answered on 05 Jul 2010, 05:34 PM
Hello Wagner,

 When you export with the ExcelML format, the correct extension is .xml, not .xls. That is why Excel complains.

Best wishes,
Yavor Georgiev
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
Wagner
Top achievements
Rank 1
answered on 08 Jul 2010, 05:15 AM
The problem is that the .xml extension it is generally associated with other programs not Excel (for example, Internet Explorer).  Is there a way to export as a .xls file and not get the Excel warning message? Or another extension that is guaranteed to be assigned to Excel.

Thanks in advance,

Wagner
0
Vlad
Telerik team
answered on 08 Jul 2010, 08:38 AM
Hi Wagner,

 This file (with ExcelML content) will be recognized automatically as MS Excel file.

Kind regards,
Vlad
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
Kristjan Einarsson
Top achievements
Rank 1
answered on 14 Jan 2011, 04:16 PM
I used
datagrid.Export(stream,
                     new GridViewExportOptions()
                     {
                         Format = ExportFormat.ExcelML,
                         ShowColumnHeaders = true,
                         ShowColumnFooters = true,
                         ShowGroupFooters = false,
                     });
and used xml extension, had no problems double clicking on the file and it opened in excel without the error messages.

 
0
KENNETH
Top achievements
Rank 1
answered on 17 Jan 2011, 02:08 AM
Exporting to ExcelML is fine unless I have grouped by a column. In this case I get garbage like
[QCVG: Key=Chicago, IL; ItemCount=3; HasSubgroups=False; ParentGroup=[QCVG: Key=Root; ItemCount=7; HasSubgroups=True; ParentGroup=null];]; (unless I set ShowGroupFooters=false)

However, the real problem is that the grouping value is not displayed in my Excel file.
0
Vlad
Telerik team
answered on 17 Jan 2011, 08:33 AM
Hello,

 You should use the ElementExporting event to set cell values for group footers as shown in our demo. 

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>>
0
KENNETH
Top achievements
Rank 1
answered on 17 Jan 2011, 10:00 AM
Thanks Vlad, but the example has the same problem that I tried to describe. If I group by Name then I see a group header which says, among other things, "Boston Crab Meat". This row header is what I need to appear in the Export file. Is this possible?
0
Vlad
Telerik team
answered on 17 Jan 2011, 10:26 AM
Hi,

 Indeed the group row header will appear in the exported file (only the header however without aggregates). You can check the demo for reference - the WPF version is exactly the same. 

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>>
0
KENNETH
Top achievements
Rank 1
answered on 17 Jan 2011, 11:59 PM
Hi Vlad,
I ran the Telerik demo, grouped by Name and exported to ExcelML. Then I double-clicked on the file to load it into Excel. Here is what I got (see screendump). I cannot see the group header. Can you? I can see a group FOOTER, but no HEADER. (I tried it in both the WPF and Silverlight demos just in case they were different - neither worked. The screendump is the WPF version.)

Hope you can help. 
0
Vlad
Telerik team
answered on 18 Jan 2011, 08:20 AM
Hi,

 Unfortunately ExcelML does not support this. Please use HTML exporting instead. 

Greetings,
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>>
Tags
GridView
Asked by
Jon
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Jon
Top achievements
Rank 1
Wagner
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Kristjan Einarsson
Top achievements
Rank 1
KENNETH
Top achievements
Rank 1
Share this question
or