Excel Export - Unreadable Data

3 posts, 1 answers
  1. Kurt Kluth
    Kurt Kluth avatar
    167 posts
    Member since:
    Oct 2009

    Posted 20 Dec 2016 Link to this post

    We currently output our data to a Grid and then export to XLSX, however we are experiencing a unique problem with one of the records.  The record in question returns the word "Infinity" and it causes a problem with opening the Excel document.  We receive the following error message:

    "Excel found unreadable content in '....aspx'.  Do you want to recover the contents of this workbook?  If you trust the source of this workbook, click Yes."

    Clicking Yes will repair the worksheet.  

    After doing much testing to narrow down what record it is failing on, we have concluded it is failing on this record with the word "Infinity".  If I change the database record to "Infinity CU", there is no problems and the Excel file will open properly.  If I save the Excel document after all these messages, it will save properly and once reopened it will be successful.  CUName is the field that it fails on. 

    I am including the code that displays the grid but might you offer a suggestion on how to remedy this problem?

    <telerik:RadGrid ID="_grdInvisibleGridForExcel" runat="server" Visible="false" HeaderStyle-Font-Bold="true" HeaderStyle-BackColor="#4F9A25" HeaderStyle-ForeColor="White"  CellSpacing="-1" GridLines="Both" GroupPanelPosition="Top" AutoGenerateColumns="false" ExportSettings-Excel-Format="ExcelML">
                        <telerik:GridDateTimeColumn DataField="Financial Date" HeaderText="Financial Date" UniqueName="FinancialDate" FilterControlAltText="Filter FinancialDate column"></telerik:GridDateTimeColumn>
                        <telerik:GridBoundColumn DataField="charter_Num" HeaderText="Charter #" UniqueName="CharterNum" FilterControlAltText="Filter CharterNum column"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="asi_Num" HeaderText="ASI #" UniqueName="AsiNum" FilterControlAltText="Filter AsiNum column"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="cuName" HeaderText="CU Name" UniqueName="cuName" FilterControlAltText="Filter cuName column"></telerik:GridBoundColumn>



  2. Answer
    Vasil avatar
    1642 posts

    Posted 23 Dec 2016 Link to this post

    Hi Kurt,

    We will investigate this further to fix it if it happens to be a bug.

    Meanwhile you may want to set string format to cells belonging to your bound columns based on this example code:
    protected void RadGrid1_InfrastructureExporting(object sender, GridInfrastructureExportingEventArgs e)
        var rows = e.ExportStructure.Tables[0].Rows;
        var rowCount = rows.Count;
        for (int rowIndex = 1; rowIndex <= rowCount; rowIndex++)
            for (int i = 2 /* starting for second since your first column is datetime*/; i <= rows[rowIndex].Cells.Count; i++)
                rows[rowIndex].Cells[i, rowIndex].Format = "@";

    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Kurt Kluth
    Kurt Kluth avatar
    167 posts
    Member since:
    Oct 2009

    Posted 23 Dec 2016 in reply to Vasil Link to this post


    Thank you for the response and we will have to keep this information in mind.  Would this still work if after the 1st 4 columns (not supplied) contained numbers and currency fields?

    We ended up rewriting the report using Telerik Reporting and sending the output to Excel and it solved our needs but glad to know we could have solved the problem just a simply using this method.

Back to Top