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

Unable to Export From Grid with IE 9.0

6 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hunter
Top achievements
Rank 1
Hunter asked on 02 Sep 2012, 10:01 PM
I have a grid and when I try to export the data to Excel, CSV or Word it wants to open the entire html page.  This happens only when I choose the "Open" option - it works fine if I click "Save" or "Save as".  It also works fine with Firefox if I "Open" the spreadsheet. 

In IE9 when I click on any of the buttons and select "Open" I get the message: "RadGrid.xls can't be downloaded".  If I click on "Retry" and there isa temporary message saying "running security scan".  Then it opens Excel and a dialog box comes up with this message:

The file you are trying to open, 'RadGridExport.xls', 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.

I take the option and say 'Yes' and it basically loads the entire aspx page into Excel.

The site is not SSL.  (Some comments in the forum had solutions for when the site was SSL). 

The grid is hierarchical with grouping.  But it still does not work when I remove the grouping and I collapse all the nested data.  In the code I have removed the NeedDataSource as they work fine to generate the table and I doubt they are the issue (if I'm wrong, I can post this too.)  I also removed a tabstrip and some additional controls that allow me to filter the data source.  (Again I will post if needed.)

Any help is appreciated.

Here is the code:

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
 
If Not IsPostBack Then
 
    RadAjaxManager.GetCurrent(Me.Page).ClientEvents.OnRequestStart = "onRequestStart"
 
End if
End Sub


 

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 
 
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"  >
        <AjaxSettings>
 
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
    </telerik:RadAjaxManagerProxy>
 
  
 <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" AutoGenerateColumns="false" Width="1000"
         GridLines="Both" Skin="Sunset"  ShowGroupPanel="true"
        AllowFilteringByColumn="False" AllowPaging="True" AllowSorting="True"
        OnDetailTableDataBind="RadGrid1_DetailTableDataBind" Height="500px"
         OnNeedDataSource="RadGrid1_NeedDataSource">
        <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" HideStructureColumns="true">
 
        </ExportSettings>
 
     <ClientSettings AllowColumnHide="True" AllowColumnsReorder="True" AllowGroupExpandCollapse="True" ReorderColumnsOnClient="True" AllowDragToGroup="True"
>
         <Scrolling AllowScroll="True" UseStaticHeaders="True" />
         <Resizing AllowColumnResize="true" AllowRowResize="true" />       
     </ClientSettings>
    <MasterTableView  DataKeyNames="ClientAlertID" CommandItemDisplay="Top">
        <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton="true" ShowAddNewRecordButton=false />
 
        <DetailTables>
            <telerik:GridTableView Name="Events" Width="100%" AutoGenerateColumns="false" AllowPaging="true"
                AllowSorting="true"  HierarchyDefaultExpanded="true"   >
                <HeaderStyle CssClass="InnerHeaderStyle" />
                <ItemStyle CssClass="InnerItemStyle" />
                <AlternatingItemStyle CssClass="InnerAlernatingItemStyle" />
                <FilterItemStyle CssClass="InnerHeaderStyle" />
                <PagerStyle CssClass="InnerHeaderStyle" />
                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
 
                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="OpenDate" ItemStyle-Width=135 HeaderStyle-Width="135"  FilterControlWidth="100"
                        FilterControlAltText="Filter OpenDate column" HeaderText="Open Date" ReadOnly="True"
                        SortExpression="OpenDate" UniqueName="OpenDate"  />
                    <telerik:GridBoundColumn DataField="device_vendor" ItemStyle-Width=75  HeaderStyle-Width="75" FilterControlWidth="45"
                        FilterControlAltText="Filter device_vendor column" HeaderText="Device Vendor" ReadOnly="True"
                        SortExpression="device_vendor" UniqueName="device_vendor" />
                    <telerik:GridBoundColumn DataField="device_type"  ItemStyle-Width="75" HeaderStyle-Width="75" FilterControlWidth="45"
                        FilterControlAltText="Filter device_type column" HeaderText="Device Type" ReadOnly="True"
                        SortExpression="device_type" UniqueName="device_type" />
                    <telerik:GridBoundColumn DataField="Description"
                        FilterControlAltText="Filter Description column" HeaderText="Description" ReadOnly="True"
                        SortExpression="Description" UniqueName="Description" />
                    <telerik:GridBoundColumn DataField="event_name" ItemStyle-Width="75" HeaderStyle-Width="75" FilterControlWidth="45"
                        FilterControlAltText="Filter event_name column" HeaderText="Correlation Rule" ReadOnly="True"
                        SortExpression="event_name" UniqueName="event_name" />
                </Columns>
 
                <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                </EditFormSettings>
 
                <HeaderStyle BackColor="Brown"></HeaderStyle>
            </telerik:GridTableView>
        </DetailTables>
 
        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
        <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
 
        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
        <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="AlertType" FieldName="AlertType"></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="AlertType"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
 
        <Columns>
            <telerik:GridBoundColumn DataField="ClientAlertID"   ItemStyle-Width=50  HeaderStyle-Width="50"
                FilterControlAltText="Filter ClientAlertID column" HeaderText="Alert ID" ReadOnly="True" AllowFiltering="false"
                SortExpression="ClientAlertID" UniqueName="ClientAlertID" />
            <telerik:GridBoundColumn DataField="AlertType"  ItemStyle-Width=150 FilterControlWidth="120" HeaderStyle-Width="150"
                FilterControlAltText="Filter AlertType column" HeaderText="Alert Type" ReadOnly="True"  AllowFiltering="false"
                SortExpression="AlertType" UniqueName="AlertType" />
            <telerik:GridBoundColumn DataField="Priority"  ItemStyle-Width=75 FilterControlWidth="45" HeaderStyle-Width="75"
                FilterControlAltText="Filter Priority column" HeaderText="Priority" ReadOnly="True"  AllowFiltering="false"
                SortExpression="Priority" UniqueName="Priority" />
            <telerik:GridBoundColumn DataField="CreationTime"  ItemStyle-Width=135 FilterControlWidth="100" HeaderStyle-Width="135"
                FilterControlAltText="Filter CreationTime column" HeaderText="Creation Time" ReadOnly="True"  AllowFiltering="false"
                SortExpression="CreationTime" UniqueName="CreationTime" />
            <telerik:GridBoundColumn DataField="Dest"
                FilterControlAltText="Filter Dest column" HeaderText="Dest IP" ReadOnly="True"  AllowFiltering="false"
                SortExpression="Dest" UniqueName="Dest" />
            <telerik:GridBoundColumn DataField="Source"
                FilterControlAltText="Filter Source column" HeaderText="Source IP" ReadOnly="True"  AllowFiltering="false"
                SortExpression="Source" UniqueName="Source" />
            <telerik:GridBoundColumn DataField="EventName"
                FilterControlAltText="Filter EventName column" HeaderText="Event Name" ReadOnly="True"  AllowFiltering="false"
                SortExpression="EventName" UniqueName="EventName" />
        </Columns>
 
        <EditFormSettings>
        <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <GroupingSettings ShowUnGroupButton="true" />
 
    <FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>
 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"
    InitialDelayTime="500" >
    </telerik:RadAjaxLoadingPanel>
 
 
    <script type="text/javascript">
        function onRequestStart(sender, args) {
            if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
                args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
                args.get_eventTarget().indexOf("ExportToCsvButton") >= 0) {
                args.set_enableAjax(false);
            }
        }
</script>
 
</asp:Content>


6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Sep 2012, 08:56 AM
Hello Hunter,

I believe I know this problem. If I'm right, it happens only in Internet Explorer and only when you try to open the file directly. The easiest way to sidestep it would beto use the "Save and open" option instead of just "Open". I attached a screenshot to this post..
You can also try to toggle the OpenInNewWindow property to see if it has any effect on this behavior.

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
Michael O'Flaherty
Top achievements
Rank 2
answered on 20 Mar 2013, 08:10 PM
Hi!

I added an Excel and PDF export button to the Rad Grid command bar and in the code behind for the PDF, I am doing this:
protected void imageButtonExportToPDF_Click(object sender, ImageClickEventArgs e)
        {
            radGridPlacements.ExportSettings.IgnorePaging = true;
            radGridPlacements.ExportSettings.ExportOnlyData = false;
            radGridPlacements.ExportSettings.OpenInNewWindow = true;
            radGridPlacements.ExportSettings.Pdf.AllowAdd = false;
            radGridPlacements.ExportSettings.Pdf.AllowModify = false;
 
            CMISUser cmisUser = Security.GetCMISUserObject();
            radGridPlacements.ExportSettings.Pdf.Author = cmisUser.Username;
            radGridPlacements.ExportSettings.Pdf.Creator = cmisUser.Username;
 
            radGridPlacements.ExportSettings.Pdf.Subject = "Placements";
            radGridPlacements.ExportSettings.Pdf.Title = "Placements";
 
            radGridPlacements.MasterTableView.ExportToPdf();
        }

I am getting an error stating the PDF file is corrupt. It does not matter whether I am opening in the same window, a new window, or whether I open it immediately or save it. I was sifting through the forums and found this thread which is exactly what I am getting. We are running the latest version of the tools, so I would assume the hot fixes and such are already rolled in. We do use AJAX but that is bypassed and the Excel export is working.

Is this a known issue with IE9?
0
Daniel
Telerik team
answered on 25 Mar 2013, 07:17 PM
Hello Michael,

Can you please help me to reproduce the problem? I need to recreate the problem on my end otherwise it would be very hard to guess what's wrong in this case. By the way, are you saying that you have already tried the same in other browsers?

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
Michael O'Flaherty
Top achievements
Rank 2
answered on 25 Mar 2013, 07:37 PM
Hi!

I opened up a support ticket. We are only using IE8 and IE9, so I have not tried this on any other browsers. I was mentioning that the Excel export (which uses this same approach) works well in the same browsers.

Thanks!
0
Daniel
Telerik team
answered on 28 Mar 2013, 02:48 PM
Hello Michael,

Ok, we will continue the conversation in the support ticket. When the issue is resolved we can update the forum thread so that the resolution is publicly available to the other customers.

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
Michael O'Flaherty
Top achievements
Rank 2
answered on 04 Apr 2013, 01:38 PM
Hi! After further analysis, we are customizing the grids too much for this to work. It would be easier for us to write a custom PDF report instead of trying to make this work through your interface. We are pleased with the Excel functionality you provide, so we will encourage the users to create PDFs through Excel worse case. (Translation--my boss will not allow me time to chase this down.) Thanks for your help!
Tags
Grid
Asked by
Hunter
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Michael O'Flaherty
Top achievements
Rank 2
Share this question
or