[SalesForce] Visualforce to Excel: Prevent long number from being displayed in Scientific Notation

I have a Visual page which offers the capability of exporting a data table to Excel.

There is a text field called Account number. Some account numbers are more than 12 digits long. When such numbers are exported to Excel, they are shown by default in the scientific format.

12345678912345 becomes 1.23457E+13

Currently my code for this column is:

  <apex:column headerValue="Account Number">                   
            <apex:outputText value="{!mt.Account_Number__c}"/>                                     
   </apex:column>

I tried using different formatting options but they didn't work. Also tried using Apex:OutputField without success.

I tried some solutions like adding css but that did not help either.

https://stackoverflow.com/questions/4619909/format-html-table-cell-so-that-excel-formats-as-text

I know this is Excel's default behavior with numbers with 12 digits or more.
Any ideas as to how I can force it to display them as Strings in my Visual force page?

Thanks.

Best Answer

Try to insert html blanks to the start and end of the string:

<apex:column headerValue="Account Number">                   
    <apex:outputText value="&nbsp;{!mt.Account_Number__c}&nbsp;" escape="false"/>
</apex:column>