Export to Excel issue..

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
 
A

Alvin Bruney [MVP]

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
 
K

karthick

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

Happy days...

Karthick
 
N

nil

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
 
K

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
 
N

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top