473,775 Members | 2,206 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export to Excel issue..

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

Feb 16 '07 #1
5 2819
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
"karthick" <ka************ *@gmail.comwrot e in message
news:11******** **************@ k78g2000cwa.goo glegroups.com.. .
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

Feb 19 '07 #2
Ok, I sorted this out by formatting like this: ="71646E100" . This
outputs cleanly in Excel like: 71646E100

Happy days...

Karthick
On Feb 19, 1:51 am, "Alvin Bruney [MVP]" <some guy without an email
addresswrote:
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 andwww.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley

"karthick" <karthick.tho.. .@gmail.comwrot e in message

news:11******** **************@ k78g2000cwa.goo glegroups.com.. .
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

Feb 19 '07 #3
nil
On Feb 19, 3:44 am, "karthick" <karthick.tho.. .@gmail.comwrot e:
Ok, I sorted this out by formatting like this: ="71646E100" . This
outputs cleanly in Excel like: 71646E100

Happy days...

Karthick

On Feb 19, 1:51 am, "Alvin Bruney [MVP]" <some guy without an email

addresswrote:
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 andwww.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"karthick" <karthick.tho.. .@gmail.comwrot e in message
news:11******** **************@ k78g2000cwa.goo glegroups.com.. .
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
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

Feb 20 '07 #4
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)Sessi on["MultiDet"];
// I am getting the Gridview from the session...

Response.Clear( );
Response.AddHea der("content-disposition",
"attachment;fil ename=Sample.xl s");
Response.Charse t = "";

Response.Conten tType = "applicatio n/vnd.xls";
System.IO.Strin gWriter stringWrite = new
System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter htmlWrite = new
HtmlTextWriter( stringWrite);

gvDet.RenderCon trol(htmlWrite) ;
Response.Write( stringWrite.ToS tring());
Response.End();

Hth,
Karthick

On Feb 20, 9:50 am, "nil" <NileshThakker. ..@gmail.comwro te:
On Feb 19, 3:44 am, "karthick" <karthick.tho.. .@gmail.comwrot e:
Ok, I sorted this out by formatting like this: ="71646E100" . This
outputs cleanly inExcellike: 71646E100
Happy days...
Karthick
On Feb 19, 1:51 am, "Alvin Bruney [MVP]" <some guy without an email
addresswrote:
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
>ExcelService s for .NET is coming...
OWC Black book on Amazon andwww.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"karthick" <karthick.tho.. .@gmail.comwrot e in message
>news:11******* *************** @k78g2000cwa.go oglegroups.com. ..
Hi,
I am exporting a Gridview toExceland 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) inExcel. How can I prevent
this from happening ?. I need to value to be inExcelas it is
displayed in the Gridview (on the web page).
>
Any help is much appreciated. Thanks.
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

Feb 20 '07 #5
nil
On Feb 20, 6:42 am, "karthick" <karthick.tho.. .@gmail.comwrot e:
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)Sessi on["MultiDet"];
// I am getting the Gridview from the session...

Response.Clear( );
Response.AddHea der("content-disposition",
"attachment;fil ename=Sample.xl s");
Response.Charse t = "";

Response.Conten tType = "applicatio n/vnd.xls";
System.IO.Strin gWriter stringWrite = new
System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter htmlWrite = new
HtmlTextWriter( stringWrite);

gvDet.RenderCon trol(htmlWrite) ;
Response.Write( stringWrite.ToS tring());
Response.End();

Hth,
Karthick

On Feb 20, 9:50 am, "nil" <NileshThakker. ..@gmail.comwro te:
On Feb 19, 3:44 am, "karthick" <karthick.tho.. .@gmail.comwrot e:
Ok, I sorted this out by formatting like this: ="71646E100" . This
outputs cleanly inExcellike: 71646E100
Happy days...
Karthick
On Feb 19, 1:51 am, "Alvin Bruney [MVP]" <some guy without an email
addresswrote:
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
ExcelServices for .NET is coming...
OWC Black book on Amazon andwww.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"karthick" <karthick.tho.. .@gmail.comwrot e in message
news:11******** **************@ k78g2000cwa.goo glegroups.com.. .
Hi,
I am exporting a Gridview toExceland 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) inExcel. How can I prevent
this from happening ?. I need to value to be inExcelas it is
displayed in the Gridview (on the web page).
Any help is much appreciated. Thanks.
>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

Feb 21 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5246
by: Saur | last post by:
Hi, I am using an export to excel functionality from my ASP page. I have set the content type as Response.ContentType = "application/vnd.ms-excel" The data i am exporting has values like 1-2, 2-5 Now when they get exported to excel, these values get exported as 1-02-2003,2-05-2003.
4
3131
by: Gary Wright | last post by:
I have an Access 2K database split into front and back. Quite often the users want to do some data analysis that I have not created a report for so they want to export some subset of the data into and Excel spreadsheet. Since the data often comes from many different tables, I have decided to create a temporary Access table, put all the data into it then use the Docmd.TransferSpreadsheet command to output the table to a spreadsheet. In...
6
13143
by: Robin Cushman | last post by:
Hi all, I need some help -- I'm working with an A2K database, using DAO, and am trying to read records into a Crystal Report and then export it to a folder on our network as an Excel spreadsheet. I'm having trouble with my code at the point at which it hits ".ReadRecords" -- the module just runs and runs without generating anything. I've gotten this code to correctly save .rpt files without any data, but not with data, nor have I been...
4
2908
by: Prasad Dannani | last post by:
Hi, We have to export our data in sql server table to any excel sheet. We have a template to export, using oledb we are inserting rows to this template and generating the excel output. The problem here is we are getting a single quote extra in front of each cell. can anyone help us in clearing this kind of an issue. we tried sending some static strings to some columns on for taking from sql
3
2018
by: Marja Ribbers-de Vroed | last post by:
Hi, One of my clients has a strange problem with my webapplication which I think may be related to some firewall setting on his computer. On several screens in the application, it is possible to click on an icon to start an export of data to Excel. The click on the icon triggers a form submit (a post, not a get) to a blank page, thereby passing the SQL select statement to use for the Excel export. I've never had any problem reports...
13
13241
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel" HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=ABC.xls") HttpContext.Current.Response.Write(strHTML) HttpContext.Current.Response.End() However when the user tries to save it the Default File Type is Web Page(*.htm; *.html)
1
9778
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm having I'd be most appreciative. The database is already constructed, I'm just wanting to export the data to an excel file. In short, I'm hoping to export two Tables (or queries...not sure which to use - they both seem to have the same data) in...
2
1771
by: leena13 | last post by:
Hi, The number of rows in the datagrid on my page are approx. around 14130. When I click on the button that exports the records to excel sheet, the page goes blank (I observed that none of the events are firing). To confirm this is happening because of the no. of rows, I modified the SP to retrieve around only 100 records. I could export these records in the datagrid successfully. I am aware that the max no of rows to export to excel...
19
11232
by: cj2 | last post by:
#1 Is there a quick way to export a datatable to an excel file? Or delimited file? #2 Where is the appropriate Microsoft monitored group to ask about writing reports in SQL Reporting services or SQL Server Business Intelligence Development Studio or whatever it's called?
0
9625
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10115
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10056
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8944
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7466
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4024
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2857
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.