Export to Excel issue..

  • Thread starter Thread starter karthick
  • Start date Start date
K

karthick

Hi,

I am exporting a Gridview to Excel and it works fine without any
issues.

But as one of the field holds values such as "71646E100" it gets
converted to: "7.16E+104" (like a formula) in Excel. How can I prevent
this from happening ?. I need to value to be in Excel as it is
displayed in the Gridview (on the web page).

Any help is much appreciated. Thanks.

Karthick
 
Ya, that's an ugly issue. You could find the cell in question and pre-pend a
"'" before it. That would work. I haven't found anything cleaner though.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
 
Ok, I sorted this out by formatting like this: ="71646E100". This
outputs cleanly in Excel like: 71646E100

Happy days...

Karthick
 
Ok, I sorted this out by formatting like this: ="71646E100". This
outputs cleanly in Excel like: 71646E100

Happy days...

Karthick

Hello,
my self nil...i want also export my datagrid data to excel..can you
provide me code or link that contains similar content to export data
to excel....
I'll be thankful to you and if you know how to export grid data in to
pdf then also provide me ...

Thanks & Regards,
Nil
 
Hi Nil,

I haven't tried exporting to a PDF; not sure if you can do it...but
here is the code for exporting a Gridview/datagrid to excel:

GridView gvDet = (GridView)Session["MultiDet"];
// I am getting the Gridview from the session...

Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename=Sample.xls");
Response.Charset = "";

Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);

gvDet.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();

Hth,
Karthick
 
Hi Nil,

I haven't tried exporting to a PDF; not sure if you can do it...but
here is the code for exporting a Gridview/datagrid to excel:

GridView gvDet = (GridView)Session["MultiDet"];
// I am getting the Gridview from the session...

Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename=Sample.xls");
Response.Charset = "";

Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);

gvDet.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();

Hth,
Karthick

Hello,
my self nil...i want alsoexportmy datagrid data toexcel..can you
provide me code or link that contains similar content toexportdata
toexcel....
I'll be thankful to you and if you know how toexportgrid data in to
pdf then also provide me ...
Thanks & Regards,
Nil

Thanks for reply and i'll try out this code at my place and let you
know whether it is working or not as i am using
vb.net 2003 so i don't know whether it will work or not..

once again thanks a lot

Regards
Nil
 
Back
Top