• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

Error while exporting to Excel with Gridview

Hello all,

I'm getting some errors while exporting the data in my gridview to excel. I have a column called account number which is not showing properly in Excel.

For example, the account number 9001022199001 is showing up as 9.00103E+12. But when I click on the field in Excel, it shows up correctly. I think its a formatting error in Excel but I'm not sure if the problem is Excel or my code.  

How can I fix this problem?
protected void Button1_Click(object sender, EventArgs e)
        GridView gTempViewForExcelExport = new GridView();
        gTempViewForExcelExport.DataSource = m_dsContractorData;
        gTempViewForExcelExport.AllowPaging = false;
        GridViewExportToExcel.Export("BulkExtract.xls", gTempViewForExcelExport);
    protected void gvUsers_RowDataBound(object sender, GridViewRowEventArgs e)
        if (((GridViewRowEventArgs)e).Row.RowType == DataControlRowType.DataRow)
            ((GridViewRowEventArgs)e).Row.Cells[1].Attributes.Add("class", "text");

Open in new window

  • 2
1 Solution
Discussed here:

The code snippets there look to be what you're after
Bob LearnedCommented:
Wow, pointing to an article that the asker asked in a different forum--what are the odds *BIG GRIN*.
Sorry - my bad - I didn't look at the usernames!
AvinashKNAuthor Commented:
Haha, It's ok. I obviously figured out what to do. Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now