Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am exporting a data from Data grid view to XLS file and i have column which is has String values but values are numbers. when it exported the column with numbers are coming like 3.5245E+14 like this. how to remove the + and i should get only the numbers.

Pls help


Regards
Nirmala Sarvanan
Posted
Updated 15-Jan-13 2:37am
v2
Comments
ZurdoDev 15-Jan-13 8:33am    
Can you post the code you are using to export? If it is html you can use css classes.

1 solution

Hi,

Here is a simple export to excel code that exports to excel without any problems.
Try this out...

protected void btnExportToExcel_Click(object sender, System.EventArgs e)
        {
            try
            {
                string attachment = "attachment; filename=Export.xls";
                Response.ClearContent();
                Response.AddHeader("content-disposition", attachment);
                Response.ContentType = "application/ms-excel";
                StringWriter sw = new StringWriter();
                HtmlTextWriter htw = new HtmlTextWriter(sw);

                // Create a form to contain the grid
                HtmlForm frm = new HtmlForm();
                gvSurvoyDetail.Parent.Controls.Add(frm);
                frm.Attributes["runat"] = "server";
                frm.Controls.Add(gvSurvoyDetail);
                frm.RenderControl(htw);
                Response.Write(sw.ToString());
                Response.End();
            }
            catch (Exception ex)
            {

            }
                        
        }


Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900