I've got a customer who is reporting that occasionally when exporting from the grid (and then opening the file directly rather than saving it), they receive an error message box from Excel, "Unable to read file."
I have been unable to reproduce the issue, and it doesn't happen every time for them either. Any thoughts on what could be causing this?
11 Answers, 1 is accepted
Could you try setting OpenInNewWindow property to true and let me know if this helps to prevent the error? If not, could you provide your grid declaration and the related code behind in order to investigate the issue further?
I am looking forward to your reply.
Regards,
Pavlina
Telerik
Unfortunately, I've already got that set. The grid is declared
<
telerik:RadGrid
ID
=
"RadGrid_CM"
runat
=
"server"
AllowSorting
=
"true"
AllowPaging
=
"true"
PageSize
=
"25"
AllowFilteringByColumn
=
"false"
OnDataBinding
=
"RadGrid_CM_DataBinding"
OnItemCommand
=
"RadGrid_CM_ItemCommand"
OnItemDataBound
=
"RadGrid_CM_ItemDataBound"
ShowStatusBar
=
"false"
Skin
=
"Simple"
Width
=
"100%"
>
<
MasterTableView
DataKeyNames
=
"ID"
AutoGenerateColumns
=
"false"
Width
=
"100%"
CommandItemDisplay
=
"Top"
NoMasterRecordsText
=
"No Results found."
>
<
Columns
>
...
</
Columns
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"false"
ShowRefreshButton
=
"false"
ShowExportToWordButton
=
"false"
ShowExportToExcelButton
=
"true"
ShowExportToCsvButton
=
"false"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
and then in the code behind
grid.ExportSettings.FileName = FileName + DateTime.Now.ToString("yyyyMMdd");
grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;
grid.GridLines = GridLines.Both;
grid.MasterTableView.AllowFilteringByColumn = false;
grid.MasterTableView.AllowSorting = false;
grid.ExportSettings.ExportOnlyData = true;
grid.ExportSettings.IgnorePaging = true;
grid.ExportSettings.OpenInNewWindow = true;
grid.CurrentPageIndex = 0;
grid.PageSize = int.MaxValue;
grid.DataSource = null;
grid.Rebind();
grid.MasterTableView.ExportToExcel();
I have tested the code you provided in a sample runnable page, however I was not able to replicate the "Unable to read file" error message. My test page is attached for your reference, give it a try and see what is the difference in your case.
Regards,
Pavlina
Telerik
Unfortunately we could not say why the error is thrown based on the provided information. However, if you manage to replicate the issue that your customer encounter send us an isolate project which we can debug and we will get back to you with a possible solution/fix for it.
Regards,
Pavlina
Telerik
We will be happy to help if you manage to replicate the problem.
Regards,
Pavlina
Telerik
I am able to duplicate this if you have Excel previously open.
Browser: IE11
Excel 2010
This is a problem for us as well. I am occasionally able to replicate it from the Telerik Demo page: http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/exporting/excel-export/defaultcs.aspx downloading the HTML button and selecting the "Open" option.
Browser: IE 11
Excel: MS Office Professional Plus 2010, Version 14.0.7165.5000
Indeed the described problem exists. For more information on the matter and possible solutions please refer to the sticky forum thread linked below:
http://www.telerik.com/forums/html-based-export-format-is-not-working-in-excel-2010
Regards,
Pavlina
Telerik by Progress
This problem was happening well before Microsoft released that patch that you linked to.
Having said that using ExcelML as an export option seems to work.