New to Telerik Reporting? Download free 30-day trial

How to Avoid Warning in Excel - The number in the cell is formatted as text or preceded by an apostrophe

Environment

Product Progress® Telerik® Reporting

Description

This article shows how to avod the warning in Excel indicating that "The number in the cell is formatted as text or preceded by an apostrophe" which appears if you exported integer values which are indicated as String in the report.

Solution

  1. Create a User Function that will return the records with the correct data type:
public static class ReturnTypeClass
{
    public static object ParseString(string str)
    {
        Int32 intValue;
        if (Int32.TryParse(str, out intValue))
            return intValue;
        else return str;
    }
}
  1. Register the User Function. For example, if you are using the Standalone designer, you will need to add this piece of code in the Telerik.ReportDesigner.exe.config file:
<Telerik.Reporting>
    <AssemblyReferences>
        <add name="ReturnDataType" />
    </AssemblyReferences>
</Telerik.Reporting>

Note that if you render the report in an application, the function must be registered in the configuration file of the application.

  1. Set the user function as a value of the field to return it value with the right data type:
= ReturnDataType.ReturnTypeClass.ParseString(Fields.NameOfField)
In this article