Excel Export data starting with a dash creates invalid format or file extension error

2 posts, 0 answers
  1. Phil
    Phil avatar
    2 posts
    Member since:
    Jun 2012

    Posted 11 Jul 2018 Link to this post

    When my RadGrid is exported to Excel, if one of the cell's data begins with a dash (-), I get the error message "Excel cannot open the file because the file format or file extension is not valid..." see in the attached Error.png.  If I remove leading dashes from the data by updating the database, or remove leading dashes in code before binding it to the grid, the grid exports as expected.  However this is not an sustainable or ideal solution.

    - I have tried setting the excel export to Xlsx, Html, Biff and ExcelIML in both cs code and in the designer (also tried each independent of each other):

                AuthGrid.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx;
                AuthGrid.MasterTableView.ExportToExcel();

                <ExportSettings>
                    <Excel FileExtension="xlsx" Format="Xlsx" />
                </ExportSettings>

    - I have tried notes.DataFormatString = "{0}"; and notes.DataFormatString = "&nbsp;{0}";

    I started with a slightly older version of these dlls, but also tried upgrading to newer versions:

    - Telerik.Web.Spreadsheet version 2016.3.913.40 (upgraded to 2018.3.620.40)

    - Telerik.Web.UI version 2016.3.914.45 (upgraded to 2018.2.710.45)

    - Telerik.Web.UI.Skins version 2016.3.914.45 (upgraded to 2018.2.710.45)

    - Telerik.Windows.Documents.Core version 2016.3.913.40 (upgraded to 2018.2.619.40)

    - Telerik.Windows.Documents.Fixed version 2016.3.913.40 (upgraded to 2018.2.619.40)

    - Telerik.Windows.Documents.Flow version 2016.3.913.40 (upgraded to 2018.2.619.40)

    - Telerik.Windows.Documents.Spreadsheet version 2016.3.913.40 (upgraded to 2018.2.619.40)

    - Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXML version 2016.3.913.40 (upgraded to 2018.2.619.40)

    - Telerik.Windows.Zip  version 2016.3.913.40 (upgraded to 2018.2.619.40)

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5354 posts

    Posted 11 Jul 2018 Link to this post

    Hi Phil,

    The minus sign can be treated as a formula beginning and that may be causing Excel to show warnings. The following article shows several ways you can remove such content when exporting so you don't have to touch the actual data: https://www.telerik.com/support/kb/aspnet-ajax/grid/details/we-found-a-problem-with-this-formula-when-exporting-to-xlsx.


    Regards,
    Marin Bratanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top