.net ----------- EXCEL exported as text format,

When the numerical data of 12 bits when scientific notation will be displayed in the cell, the numerical data can be stored up to 15 significant digits, if it exceeds 15, the unit may be previously set to a digital formatting text.

 

 

 

// eliminate long numbers automatically derived into an Excel scientific notation 
for ( int I = 0 ; I <e.Row.Cells.Count; I ++ )
{
    e.Row.Cells[i].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
}

 

 

 

 

front

     
<div id="divGrid" runat="server">
            <asp:GridView ID="GridViewData" runat="server" OnRowDataBound="GridViewData_RowDataBound">
            </asp:GridView>
</div>
        

  

Behind

 protected void GridViewData_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        GridViewRow gvr = e.Row;
        for(int i=0;i<=gvr.Cells .Count -1;i++)
        {
            gvr.Cells[i].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
        }
    }

Guess you like

Origin www.cnblogs.com/obge/p/12106637.html