RadGrid export to excel with warning message

18 posts, 0 answers
  1. zorro
    zorro avatar
    8 posts
    Member since:
    Mar 2009

    Posted 13 Jul 2012 Link to this post

    Hi team,

    I found many thread about this issue. Like below

    http://www.telerik.com/community/forums/wpf/gridview/export-to-excel-2007.aspx
    http://www.telerik.com/community/forums/aspnet-ajax/grid/excel-export-the-file-you-are-trying-to-open-filename-is-in-a-different-format-than-specified-by-the-file-extension.aspx

    And the link how to fix (use registry)
    http://www.itexperience.net/2008/03/17/excel-2007-error-different-format-than-specified-by-the-file-extension/

    But seem, it was before 2012. Our client has concern this warning message. So I would like to receive the ways to solve but not use Registry.

    Thanks.

  2. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 17 Jul 2012 Link to this post

    Hello Kim,

    The warning message you received is seen only with the HTML-based Excel export. Now we have introduced a new Excel export format (in Q2 2012) which is based on a binary XLS (BIFF) format and is supported in all versions of Microsoft Office, starting from 2003. With it, there is no longer a warning message when you open the exported file. To see the new Excel export in action, you can check this demo: http://demos.telerik.com/aspnet-ajax/grid/examples/export/biffexport/defaultcs.aspx

    All the best,
    Kostadin
    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.
  3. Telugu
    Telugu avatar
    5 posts
    Member since:
    Nov 2012

    Posted 29 Nov 2012 Link to this post

    RadGrid export to excel with warning message


    "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
  4. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 03 Dec 2012 Link to this post

    Hi Telugu,

    If you would like to avoid this message you have to use our latest Excel export format which is based on a binary XLS (BIFF) format. Additional information about this warning could be found at the following help topics.
    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"

    Greetings,
    Kostadin
    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.
  5. Radha
    Radha avatar
    19 posts
    Member since:
    Dec 2012

    Posted 20 Feb 2013 Link to this post

    Hi Kostadin,

         With the new format "BIFF" can we use old events like below or do we need to rewrite the code accordingly.

     

    protected void grdReport_ExcelMLExportRowCreated(object sender, GridExportExcelMLRowCreatedArgs e)

     

    {


    }

    protected

     

    void grdReport_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)

     

    {


    }

    Please suggest.

    Regards,
    Radha
  6. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 25 Feb 2013 Link to this post

    Hello Radha,

    I am afraid you could not use those events when using BIFF Export. There is a separate event called BiffExporting. You could find more information at the following help article. Additionally you could check out the following live example.

    All the best,
    Kostadin
    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.
  7. Priyalakshmi
    Priyalakshmi avatar
    12 posts
    Member since:
    Jul 2012

    Posted 09 May 2013 Link to this post

    Hi Kostadin,

    I am also facing the same problem while exporting data to excel. But I am using WPF. Is the new component(BIFF Export).
    available for wpf? Please help.


    Regards,
    Priyalakshmi
  8. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 14 May 2013 Link to this post

    Hi Priyalakshmi,

    I am afraid that Biff export is not supported in WPF. More information could be found at the following help article. If you have any further question I would suggest you to open a new forum thread in WPF forums as in this case you could receive more to the point answer.

    Kind regards,
    Kostadin
    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.
  9. May
    May avatar
    1 posts
    Member since:
    Sep 2011

    Posted 23 May 2013 Link to this post

    I am using telerik 2013 version to export excel from the radgrid. However the window authentication keep reprompting. I typed in username and password and it the window authentication still reprompting. I also tried to use the OpenINNewWindow in the setting but that does not take care of the problem. Anything I can do?

    It seems it only happens in IE not Chrome.

    Thanks!


  10. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 28 May 2013 Link to this post

    Hi May,

    Could you please elaborate a little bit more on your scenario? Are you experience this behavior only when opening a file? Could you please try saving it instead opening and let me know about the result?

    Regards,
    Kostadin
    Telerik
    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.
  11. SC
    SC avatar
    2 posts
    Member since:
    Nov 2014

    Posted 05 Dec 2014 Link to this post

    Hello

    I have a different issue. 
    click on export, i receive open/save dialog click on "Open",  receive a warning which is fine i click on "No", again warning window is displayed click on "No" again , my page goes blank.
    What might be going wrong?

    Thanks
    Sc
  12. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 10 Dec 2014 Link to this post

    Hi Sc,

    In order to open the file you have to click Yes button. More information about this warning message could be found at the beginning of the following help article.

    Regards,
    Kostadin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  13. Sumila
    Sumila avatar
    7 posts
    Member since:
    Sep 2018

    Posted 16 Oct 2018 Link to this post

    Hello Team,

     

    I face an issue while using 'Xlsx' while Export to Excel. I do development on a Virtual desktop which has VS 2015. Also this desktop does not have Microsoft Office installed(Hope this is not a limitation but just want to add). I am copying the error below,

    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Web.UI.GridExpandColumn.PrepareCell(TableCell cell, GridItem item) +2865
       Telerik.Web.UI.GridItemDecorator.DecorateItem(GridTableView owner, GridColumn[] columnArray) +510
       Telerik.Web.UI.GridInfrastructureExporter.CreateRow(GridItem currentItem, Int32& invisibleRows, Int32 row, Boolean isMultiRow) +455
       Telerik.Web.UI.GridInfrastructureExporter.GenerateStructure() +654
       Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderForm(HtmlTextWriter nullWriter, Control form) +1749
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +116
       System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +130
       System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +46
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +78
       System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +49
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +116
       System.Web.UI.Page.Render(HtmlTextWriter writer) +38
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +78
       Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +952
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +116
       System.Web.UI.Page.Render(HtmlTextWriter writer) +38
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +78
       Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +952
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +116
       System.Web.UI.Page.Render(HtmlTextWriter writer) +38
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +78
       System.Web.UI.<ProcessRequestMainAsync>d__523.MoveNext() +13204

    Kindly help.

  14. Attila Antal
    Admin
    Attila Antal avatar
    202 posts

    Posted 19 Oct 2018 Link to this post

    Hi Sumila,

    Could you share some more details? For instance, I would like to see the markup of the grid as well if there is logic in the code behind that fires when exporting is clicked. RadGrid includes the necessary assemblies for exporting, and can export without the Office application installed.

    I look forward to hearing from you. 

    Kind regards,
    Attila Antal
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  15. Sumila
    Sumila avatar
    7 posts
    Member since:
    Sep 2018

    Posted 22 Oct 2018 in reply to Attila Antal Link to this post

    Hi,

    There is a custom Radgrid defined for the project. The code excerpts are copied here.

    <telerik:RadGrid RenderMode="Lightweight" ID="gvDynamicGrid" runat="server" Skin="Office2007" ShowStatusBar="true" AutoGenerateColumns="False"
            PageSize="30" AllowSorting="True" AllowPaging="True" ClientIDMode="AutoID"
            ClientSettings-AllowGroupExpandCollapse="true" ClientSettings-AllowExpandCollapse="true" EnableViewState="true" MasterTableView-EnableViewState="true"
            EnableHeaderContextFilterMenu="true" EnableHeaderContextMenu="false" EnableLinqExpressions="false" RetainExpandStateOnRebind="true"
            OnDetailTableDataBind="gvDynamicGrid_DetailTableDataBind"
            OnNeedDataSource="gvDynamicGrid_NeedDataSource"
            OnItemCreated="gvDynamicGrid_ItemCreated"
            OnPreRender="gvDynamicGrid_PreRender"
            OnSortCommand="gvDynamicGrid_SortCommand"
            onmousedown="onGv_gvDynamicGrid_MouseDown(event);"
            onmousemove="onGv_gvDynamicGrid_MouseMove(event);"
            onmouseup="onGv_gvDynamicGrid_MouseUp(event);">
            <PagerStyle Mode="NumericPages" Visible="false"></PagerStyle>
            <MasterTableView EnableViewState="true" Name="MasterTable">
                <DetailItemTemplate>
                    <asp:Table ID="tblOrderItemdescription" runat="server" CellPadding="0" CellSpacing="0" CssClass="fontGrid">
                        <asp:TableRow>
                            <asp:TableCell Width="35px" />
                            <asp:TableCell Width="100%">
                                    <%# string.Format("{0}",Eval("Description")) %>
                            </asp:TableCell>
                        </asp:TableRow>
                    </asp:Table>
                </DetailItemTemplate>
                <NoRecordsTemplate>
                    <telerik:RadLabel runat="server" ClientIDMode="Static" ID="lblNoRecord" Text="No records are found."
                        CssClass="norecord">
                    </telerik:RadLabel>
                </NoRecordsTemplate>
            </MasterTableView>
            <ClientSettings AllowRowsDragDrop="false" ColumnsReorderMethod="Reorder" AllowColumnsReorder="true" ReorderColumnsOnClient="true">

                <Resizing AllowColumnResize="True" AllowRowResize="false" ResizeGridOnColumnResize="true"
                    ClipCellContentOnResize="true" EnableRealTimeResize="true" AllowResizeToFit="true" />
                <ClientEvents OnColumnCreated="onDynamicGridColumnCreated" OnScroll="HandleScrolling"
                    OnColumnSwapped="onDynamicGridColumnSwapped"
                    OnCellSelected="DynamicGridcellSelected"
                    OnRowDblClick="DynGridRowDblClick"
                    OnRowContextMenu="RowContextMenuDynGrid"
                    OnRowClick="DynGridOnRowClick"
                    OnColumnResized="DynGridColumnResized" />
                <Selecting AllowRowSelect="True" CellSelectionMode="SingleCell" EnableDragToSelectRows="false"></Selecting>
                <Scrolling AllowScroll="true" UseStaticHeaders="True" ScrollHeight="250px" />
            </ClientSettings>
        </telerik:RadGrid>                                                                                      

    Code behind is below,

     private void BuildGridTableDetails(Telerik.Web.UI.GridTableView parent)
            {
                Telerik.Web.UI.GridTableView child = null;
                if (gvDynamicGrid.MasterTableView.DetailTables.Count > 0)
                    child = gvDynamicGrid.MasterTableView.DetailTables[0];
                GridTableDetailsCollection tableCollection = ((GridBasePage)this.Page).GridTableDetailsList;

                GridTableDetails gridTableDetails = new GridTableDetails();
                if (tableCollection == null)
                {
                    tableCollection = new GridTableDetailsCollection();
                    tableCollection.GridTableDetailsList = new List<GridTableDetails>();

                    GridTableDetails grid = new GridTableDetails();
                    grid.ColumnDetailsList = new List<GridColumnDetails>();
                    grid.GridIdentifier = Convert.ToString(Session["SearchListName"]);

                    //parent grid column details
                    GridColumnDetails gridColumn = new GridColumnDetails();
                    gridColumn.GridTableColumnSettingsList = new List<Telerik.Web.UI.GridTableView.PersistableColumnSetting>();
                    gridColumn.GridTableDetailsList = new GridColumnCollection(gvDynamicGrid.MasterTableView);
                    gridColumn.GridTableDetailsList = parent.Columns;
                    gridColumn.GridTableColumnSettingsList = parent.ColumnSettings;
                    grid.ColumnDetailsList.Add(gridColumn);

                    //child column details
                    gridColumn = new GridColumnDetails();
                    gridColumn.GridTableColumnSettingsList = new List<Telerik.Web.UI.GridTableView.PersistableColumnSetting>();
                    gridColumn.GridTableDetailsList = new GridColumnCollection(gvDynamicGrid.MasterTableView.DetailTables[0]);
                    if (child != null)
                    {
                        gridColumn.GridTableDetailsList = child.Columns;
                        gridColumn.GridTableColumnSettingsList = child.ColumnSettings;

                    }
                    grid.ColumnDetailsList.Add(gridColumn);

                    tableCollection.GridTableDetailsList.Add(grid);

                }
                else
                {
                    gridTableDetails = tableCollection.GridTableDetailsList.FirstOrDefault(x => x.GridIdentifier == Convert.ToString(Session["SearchListName"]));


                    if (gridTableDetails != null)
                    {
                        gridTableDetails.ColumnDetailsList[0].GridTableDetailsList = parent.Columns;
                        gridTableDetails.ColumnDetailsList[0].GridTableColumnSettingsList = parent.ColumnSettings;
                        if (child != null)
                        {

                            gridTableDetails.ColumnDetailsList[1].GridTableDetailsList = child.Columns;
                            gridTableDetails.ColumnDetailsList[1].GridTableColumnSettingsList = child.ColumnSettings;
                        }
                    }
                    else
                    {
                        GridTableDetails grid = new GridTableDetails();
                        grid.ColumnDetailsList = new List<GridColumnDetails>();
                        grid.GridIdentifier = Convert.ToString(Session["SearchListName"]);

                        //parent grid column details
                        GridColumnDetails gridColumn = new GridColumnDetails();
                        gridColumn.GridTableColumnSettingsList = new List<Telerik.Web.UI.GridTableView.PersistableColumnSetting>();
                        gridColumn.GridTableDetailsList = new GridColumnCollection(gvDynamicGrid.MasterTableView);
                        gridColumn.GridTableDetailsList = parent.Columns;
                        gridColumn.GridTableColumnSettingsList = parent.ColumnSettings;
                        grid.ColumnDetailsList.Add(gridColumn);
                        if (child != null)
                        {
                            //child column details
                            gridColumn = new GridColumnDetails();
                            gridColumn.GridTableColumnSettingsList = new List<Telerik.Web.UI.GridTableView.PersistableColumnSetting>();
                            gridColumn.GridTableDetailsList = new GridColumnCollection(gvDynamicGrid.MasterTableView.DetailTables[0]);
                            gridColumn.GridTableDetailsList = child.Columns;
                            gridColumn.GridTableColumnSettingsList = child.ColumnSettings;
                            grid.ColumnDetailsList.Add(gridColumn);
                        }
                        tableCollection.GridTableDetailsList.Add(grid);
                    }
                }

                ((GridBasePage)this.Page).GridTableDetailsList = tableCollection;

            }

  16. Attila Antal
    Admin
    Attila Antal avatar
    202 posts

    Posted 25 Oct 2018 Link to this post

    Hi Sumila, 

    Thank you for details.

    The markup seems to be okay, but I guess the application breaks somewhere in the code behind.  I took the code snippet you have provided, I've bound some dummy data to the grid, added a RadButton that will call the ExportToExcel() method of RadGrid when clicked and the export is successful. Attached you can find the sample project I've used to test this scenario.

    I can't tell what is going on with the method you've shared as it is calling some custom classes that are not available.  If you could modify this sample to produce the error and send it back, I'd be happy to take a look.

    Kind regards,
    Attila Antal
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  17. Sumila
    Sumila avatar
    7 posts
    Member since:
    Sep 2018

    Posted 25 Oct 2018 in reply to Attila Antal Link to this post

    Hello Attila,

    This solution does not help me. I have mentioned that I am facing issue with Export format 'Xlsx'. Your sample is in HTML format. Could you please share a sample with XLsx format? Will try if this works on my virtual desktop.

     

    Thanks,

    Sumila.

  18. Attila Antal
    Admin
    Attila Antal avatar
    202 posts

    Posted 25 Oct 2018 Link to this post

    Hi Sumila,

    My sample was using the markup you have shared with me and that did not specify the export type of "XLSX".

    To export to XLSX, set the ExportSettings - Excel Format to the desired name (see XLSX and DOCX Export documentation for more).

    Once the format is configured, you will need to include the rest of the assemblies that are located in the AdditionalLibraries folder in the Telerik® UI for ASP.NET AJAX installation (see Telerik document processing libraries documentation for more).

    Once you have included those, the exporting to XLSX will work as expected.

    I hope this will help resolve the issue.

    Kind regards,
    Attila Antal
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top