• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • 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();
        PopulateGrid();
        gTempViewForExcelExport.DataSource = m_dsContractorData;
        gTempViewForExcelExport.AllowPaging = false;
        gTempViewForExcelExport.DataBind();
 
        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

0
AvinashKN
Asked:
AvinashKN
  • 2
1 Solution
 
aherpsCommented:
Discussed here:
http://forums.asp.net/p/1346109/2736506.aspx

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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