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

Excel export: The file you are trying to open, '[filename]', is in a different format than specified by the file extension

18 Answers 1038 Views
Grid
This is a migrated thread and some comments may be shown as answers.
GrZeCh
Top achievements
Rank 2
GrZeCh asked on 17 Jan 2009, 02:41 PM
Hello!

When I'm exporting to Excel (HTML or ExcelML) and when I'm opening exported file I'm getting this error/notification:

"The file you are trying to open, '[filename]', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"  (Yes | No | Help)

Is there any workaround (without changing registry/excel settings) for this to make excel not showing this question?

Thanks

EDIT: Ok. I've found solution for my problem here:

http://www.grinn.net/blog/dev/2008/06/file-you-are-trying-to-open-is-in.html

18 Answers, 1 is accepted

Sort by
0
Trent
Top achievements
Rank 1
answered on 08 Jun 2010, 01:28 PM
Has Telerik found a fix for this yet?  I recently talked my company into switching to Telerik from another third party grid control and the former excel export does not show a warning message. 
0
Daniel
Telerik team
answered on 09 Jun 2010, 09:55 PM
Hello Trent,

Unfortunately it is not possible to address this problem directly. You could suppress the warning message on the client (using a registry setting) but this is hardly a feasible option.
MSDN blogs: Excel 2007 Extension Warning On Opening Excel Workbook from a Web Site
Grinn blog: "The file you are trying to open, '[filename]', is in a different format"

As an alternative you can try a third-party library like NPOI:
Export to Excel with third-party library (NPOI)

Best regards,
Daniel
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
Trent
Top achievements
Rank 1
answered on 10 Jun 2010, 07:42 PM
Thank you Daniel.  The NPOI export works great!  It took some time to set up but it will save time in the future.
0
Murali
Top achievements
Rank 1
answered on 17 Jun 2010, 11:31 PM
Is it possible to isolate columns that I do not want to show in the excel sheet?
Previously using "gridID.MasterTableView.ExportToExcel()" one could achieve that.
But using the NPOI solution, you can hide it by making the column width less than 1, but the problem is that the columns are still created, it only hides it.
So for example, say you hid the first 4 columns and made the 5th one visible, then the excel sheet would show data beginning from "column E" instead of "column A" which is unacceptable by our customer!
I used the code excactly the way shown in the example project except for some modifications suited for my project.
0
Daniel
Telerik team
answered on 23 Jun 2010, 05:05 PM
Hello Murali,

Yes, it is possible to skip the hidden cells although this will require some modifications. I will update the code-library in the next few days.

Best regards,
Daniel
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
Trent
Top achievements
Rank 1
answered on 28 Jun 2010, 09:32 PM
As I said, it works great, if it is not a hierarchical grid.  Is there any modifications that are documented for displaying children data? 
0
Daniel
Telerik team
answered on 02 Jul 2010, 09:09 PM
Hello Trent,

Please note that this project was created to demonstrate that the NPOI library gives you enough freedom to create and export MS Excel sheet from RadGrid. The current implementation doesn't work for complicated scenarios like hierarchy and grouping since this will require a lot of code (and different approach) and will become hard to understand.

Regards,
Daniel
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
Sentha
Top achievements
Rank 1
answered on 12 Jul 2010, 09:38 PM
Hi,

I'm also getting the same error in my application while exporting to excel. But the file name it reports is different than the one I mentioned. It takes the aspx file's name and adds .xls to it. Is there a way we can change that? I tried even in the following telerik demo link.
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx

When you click on export to excel it shows the name as RadGridExport.xls. But when you click open it shows 'defaultcs.xls'. Is there a way to open the file with the same name?

Thanks,
Sentha.
0
Daniel
Telerik team
answered on 15 Jul 2010, 04:57 PM
Hello Sentha,

Internet Explorer ignores the FileName property when the content-disposition header is set to inline (e.g. when ExportSettings-OpenInNewWindow="false")

RadGrid export overview

Regards,
Daniel
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
Eric Klein
Top achievements
Rank 1
answered on 16 Jul 2010, 05:31 PM
I am having an issue with paging.  I hace set  ExportSetting.IgnorePaging = true but it still only exports the first page.  I have tried setting it before the girs is sent to the module and I have also tried to set it in the BuildTableStructure(), but still only get the first page.
0
Daniel
Telerik team
answered on 16 Jul 2010, 08:17 PM
Hello Eric,

These settings (ExportSettings) are not taken into consideration in this code-library. Please try this approach instead:
protected void Button1_Click(object sender, EventArgs e)
{
    RadGridExporter exporter = new RadGridExporter();
    exporter.FileName = "TestExport.xls";
    RadGrid1.AllowPaging = false;
    RadGrid1.Rebind();
    exporter.Export(RadGrid1);
}

Regards,
Daniel
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
Vasanth
Top achievements
Rank 1
answered on 01 Mar 2012, 08:15 AM
I am using NPOI to export to excel from rad grid and I also want to remove the hidden columns from the excel that generated through NPOI.
I saw the following post from telerik team, please let me know where can I find the code on the same. I need to remove the hidden column completely from the excel.

POST from telerik team :
Hello Murali,

Yes, it is possible to skip the hidden cells although this will require some modifications. I will update the code-library in the next few days.

Best regards,
Daniel
the Telerik team
0
Daniel
Telerik team
answered on 07 Mar 2012, 02:14 PM
Hi Vasanth,

The aforementioned code-library is no longer supported as our developers are currently working on a BIFF export for RadGrid.
Please excuse us for any inconvenience caused.

Regards,
Daniel
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.
0
IT Services
Top achievements
Rank 1
answered on 02 Apr 2012, 06:29 PM
Hi Daniel,

When will this feature (BIFF export) be implemented?

Thanks
Ping
0
Daniel
Telerik team
answered on 05 Apr 2012, 08:26 AM
Hello Ping,

I'm afraid I can't provide an exact timeframe but we will do our best to add this functionality for Q2 or Q3 releases this year.

Kind regards,
Daniel
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.
0
Meygnanam
Top achievements
Rank 1
answered on 06 Aug 2012, 12:59 PM
Dear All
  The First think is Go to Start-->Run then Type "  regedit " .After that Click on the HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security then Right Click the "Security" New-->DWORD Value then paste the " ExtensionHardening "
0
Telugu
Top achievements
Rank 1
answered on 29 Nov 2012, 09:10 AM
I am also facing same problem when opening excel file it showing message like

"The file you are trying to open, '[filename]', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"  (Yes | No | Help)

Any solution for this.

Thanks,
Praveen.
0
Daniel
Telerik team
answered on 03 Dec 2012, 05:04 PM
Hello Praveen,

I noticed that you already posted the same question in another forum post.
Please refer to the other post or to the previous answers in this thread.

Regards,
Daniel
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
GrZeCh
Top achievements
Rank 2
Answers by
Trent
Top achievements
Rank 1
Daniel
Telerik team
Murali
Top achievements
Rank 1
Sentha
Top achievements
Rank 1
Eric Klein
Top achievements
Rank 1
Vasanth
Top achievements
Rank 1
IT Services
Top achievements
Rank 1
Meygnanam
Top achievements
Rank 1
Telugu
Top achievements
Rank 1
Share this question
or