473,473 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Export to Excel truncates numbers

Hi and TIA! I'm exporting a dataset/datgrid to excel but some text fields
get converted to numbers in excel and I loose leading zero's. I've tried
several methods with no success. If anyone has come across this and can
point me in the right direction I would appreciate it. Thanks!

--

******************
Reggie
Jul 13 '08 #1
6 1945
Reggie wrote:
Hi and TIA! I'm exporting a dataset/datgrid to excel but some text fields
get converted to numbers in excel and I loose leading zero's. I've tried
several methods with no success. If anyone has come across this and can
point me in the right direction I would appreciate it. Thanks!
I'm setting followups for this question to microsoft.public.excel since this
is not a .NET-specific question.

The way to avoid is is to ensure that you are actually writing the data as
text. In formula form, it should be ="00123" and not =00123, for example.
How you do this depends on how you're doing the export. For automation, you
can use the "Formula" property of a Range object, for export, you're
probably best off with XML, as you can't specify data types in CSV.

--
J.
Jul 13 '08 #2
"Reggie" <NoSpam_chief123101@NoSpam_hotmail.comwrote in message
news:A5******************************@comcast.com. ..
Hi and TIA! I'm exporting a DataSet/DatGrid to Excel but some text fields
get converted to numbers in Excel and I oose leading zeroes. I've tried
several methods with no success. If anyone has come across this and can
point me in the right direction I would appreciate it. Thanks!
Please show your code...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 13 '08 #3
Mark, Here is a link to the code I am using
http://www.dotnetjohn.com/articles.aspx?articleid=36
here is a link (http://www.codeproject.com/KB/dotnet/ExportToExcel.aspx) to
code that looks like it would work, but I'm not exactly sure how to
implement it. Thanks for your time!

--

******************
Reggie
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eK**************@TK2MSFTNGP02.phx.gbl...
"Reggie" <NoSpam_chief123101@NoSpam_hotmail.comwrote in message
news:A5******************************@comcast.com. ..
>Hi and TIA! I'm exporting a DataSet/DatGrid to Excel but some text
fields get converted to numbers in Excel and I oose leading zeroes. I've
tried several methods with no success. If anyone has come across this
and can point me in the right direction I would appreciate it. Thanks!

Please show your code...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 14 '08 #4
Also forgot to mention I am using vb.net

--

******************
Reggie
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eK**************@TK2MSFTNGP02.phx.gbl...
"Reggie" <NoSpam_chief123101@NoSpam_hotmail.comwrote in message
news:A5******************************@comcast.com. ..
>Hi and TIA! I'm exporting a DataSet/DatGrid to Excel but some text
fields get converted to numbers in Excel and I oose leading zeroes. I've
tried several methods with no success. If anyone has come across this
and can point me in the right direction I would appreciate it. Thanks!

Please show your code...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 14 '08 #5
"Reggie" <NoSpam_chief123101@NoSpam_hotmail.comwrote in message
news:9K******************************@comcast.com. ..

[top-posting corrected]
>>Hi and TIA! I'm exporting a DataSet/DatGrid to Excel but some text
fields get converted to numbers in Excel and I oose leading zeroes.
I've tried several methods with no success. If anyone has come across
this and can point me in the right direction I would appreciate it.
Thanks!

Please show your code...

Here is a link to the code I am using
http://www.dotnetjohn.com/articles.aspx?articleid=36
That's a very old article. Have you contacted the author to see if there is
a more up-to-date version...?
Here is a link (http://www.codeproject.com/KB/dotnet/ExportToExcel.aspx)
to code that looks like it would work, but I'm not exactly sure how to
implement it.
Create a new class file and drop the code into it. Unfortunately, you're
using VB.NET so you'll either have to convert the code first, or create a
separate assembly and drop that into your project.

Then just pass it your DataSet and the path of the output file...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 14 '08 #6
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
"Reggie" <NoSpam_chief123101@NoSpam_hotmail.comwrote in message
news:9K******************************@comcast.com. ..

[top-posting corrected]
>>>Hi and TIA! I'm exporting a DataSet/DatGrid to Excel but some text
fields get converted to numbers in Excel and I oose leading zeroes.
I've tried several methods with no success. If anyone has come across
this and can point me in the right direction I would appreciate it.
Thanks!

Please show your code...

Here is a link to the code I am using
http://www.dotnetjohn.com/articles.aspx?articleid=36

That's a very old article. Have you contacted the author to see if there
is a more up-to-date version...?
>
>Here is a link (http://www.codeproject.com/KB/dotnet/ExportToExcel.aspx)
to code that looks like it would work, but I'm not exactly sure how to
implement it.

Create a new class file and drop the code into it. Unfortunately, you're
using VB.NET so you'll either have to convert the code first, or create a
separate assembly and drop that into your project.
>
Then just pass it your DataSet and the path of the output file...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Didn't notice how old that was. My bad. Creating an assembly sounds like a
good plan. I'll give it a try and let you know. Thanks!
Jul 14 '08 #7

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

Similar topics

7
by: Keon | last post by:
Hoi, I'm using a database with alot of records in 1 table (more than 3000). If i want to export this table to excel i only get it till record 2385. Do someone know how i can solve this...
1
by: Julien | last post by:
Hi, I'm actually trying to export a repeater to excel, everything seems ok but the problem is that the cells are not validated This means that for example date, it is left-centered instead of been...
8
by: John Brock | last post by:
I am creating an Excel workbook using VB.NET, and have run into a problem. Excel at times insists on reformatting data that I enter into cells, e.g., converting "01234" to "1234", and this screws...
8
by: Taffman | last post by:
I've searched this goup for an answer to this, there are many discussions that come close but non that I can find that actually addresses this particular problem. I'm exporting queries to Excel....
0
by: Jerry | last post by:
I have an application that is trying to export multiple datasets to and excel workbook in different worksheets. I have gotten the export to work except for string fields that happen to be numbers...
1
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...
2
by: mccalla | last post by:
Hi, I am very new to MS Access. I have inherited an existing app which was done in MS Access 2003. In this app, there is a report which contains a memo field. There are no formats, functions,...
5
Shakss2
by: Shakss2 | last post by:
Hi... I am exporting some data from a table with a memo field to excel but the excel report truncates the memo field data to 255 chars. Dim strPath As String ' Current path strPath =...
0
by: yoavyoavyoav | last post by:
Hi There, I have some serious issue - I have a .Net application that is generating various reports in CSV format and then fires up excel from code to view this file. The file is viewed...
1
by: Reggie | last post by:
Hi and TIA! I'm exporting a dataset/datgrid to excel but some text fields get converted to numbers in excel and I loose leading zero's. I've tried several methods with no success. If anyone has...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
1
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...
0
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.