473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Strange Excel importing problem

I have a routine that imports a list of part numbers into a dataview:

strExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
boxFile.Text & ";Extended Properties=""Excel 8.0;HDR=NO"""
cnnExcel = New OleDbConnection(strExcel)
da = New OleDbDataAdapter("Select * from [ODRJYUFI$]", cnnExcel)
da.Fill(ds, "Excel")
dv = New DataView(ds.Tables("Excel"))

This works fine exept when the following condition happens: The part
numbers are alpha-numeric. When a numeric only part number (mixed in with
alpha's) is read in, NULL is stored. The routine will read in numeric
values ONLY when all the part numbers in the spreadsheet are numeric.

I've tried formatting the column in the spreadsheet as Text to try and trick
the routine, with no luck.

Any suggestions? Thanks
Nov 21 '05 #1
5 2809
Take a look at this site:
http://www.connectionstrings.com/

There is another papramer to add in to the connection string to make certain
Excel treats intermeixed columns as text.

"Rob T" wrote:
I have a routine that imports a list of part numbers into a dataview:

strExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
boxFile.Text & ";Extended Properties=""Excel 8.0;HDR=NO"""
cnnExcel = New OleDbConnection(strExcel)
da = New OleDbDataAdapter("Select * from [ODRJYUFI$]", cnnExcel)
da.Fill(ds, "Excel")
dv = New DataView(ds.Tables("Excel"))

This works fine exept when the following condition happens: The part
numbers are alpha-numeric. When a numeric only part number (mixed in with
alpha's) is read in, NULL is stored. The routine will read in numeric
values ONLY when all the part numbers in the spreadsheet are numeric.

I've tried formatting the column in the spreadsheet as Text to try and trick
the routine, with no luck.

Any suggestions? Thanks

Nov 21 '05 #2
Works great! Thanks!

"Darrell Wesley" <Da***********@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.com...
Take a look at this site:
http://www.connectionstrings.com/

There is another papramer to add in to the connection string to make
certain
Excel treats intermeixed columns as text.

"Rob T" wrote:
I have a routine that imports a list of part numbers into a dataview:

strExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
boxFile.Text & ";Extended Properties=""Excel 8.0;HDR=NO"""
cnnExcel = New OleDbConnection(strExcel)
da = New OleDbDataAdapter("Select * from [ODRJYUFI$]", cnnExcel)
da.Fill(ds, "Excel")
dv = New DataView(ds.Tables("Excel"))

This works fine exept when the following condition happens: The part
numbers are alpha-numeric. When a numeric only part number (mixed in
with
alpha's) is read in, NULL is stored. The routine will read in numeric
values ONLY when all the part numbers in the spreadsheet are numeric.

I've tried formatting the column in the spreadsheet as Text to try and
trick
the routine, with no luck.

Any suggestions? Thanks

Nov 21 '05 #3
Perhaps I spoke a bit too soon.... that part works, but now all my date
fields are returned as an integer. Any way to convert these back to a date
type?

"Darrell Wesley" <Da***********@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.com...
Take a look at this site:
http://www.connectionstrings.com/

There is another papramer to add in to the connection string to make
certain
Excel treats intermeixed columns as text.

"Rob T" wrote:
I have a routine that imports a list of part numbers into a dataview:

strExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
boxFile.Text & ";Extended Properties=""Excel 8.0;HDR=NO"""
cnnExcel = New OleDbConnection(strExcel)
da = New OleDbDataAdapter("Select * from [ODRJYUFI$]", cnnExcel)
da.Fill(ds, "Excel")
dv = New DataView(ds.Tables("Excel"))

This works fine exept when the following condition happens: The part
numbers are alpha-numeric. When a numeric only part number (mixed in
with
alpha's) is read in, NULL is stored. The routine will read in numeric
values ONLY when all the part numbers in the spreadsheet are numeric.

I've tried formatting the column in the spreadsheet as Text to try and
trick
the routine, with no luck.

Any suggestions? Thanks

Nov 21 '05 #4
What your probably seing is the numeric value of the date field , if it is
then all you need to do is convert it back to a date in your VB program.

"Rob T" wrote:
Perhaps I spoke a bit too soon.... that part works, but now all my date
fields are returned as an integer. Any way to convert these back to a date
type?

"Darrell Wesley" <Da***********@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.com...
Take a look at this site:
http://www.connectionstrings.com/

There is another papramer to add in to the connection string to make
certain
Excel treats intermeixed columns as text.

"Rob T" wrote:
I have a routine that imports a list of part numbers into a dataview:

strExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
boxFile.Text & ";Extended Properties=""Excel 8.0;HDR=NO"""
cnnExcel = New OleDbConnection(strExcel)
da = New OleDbDataAdapter("Select * from [ODRJYUFI$]", cnnExcel)
da.Fill(ds, "Excel")
dv = New DataView(ds.Tables("Excel"))

This works fine exept when the following condition happens: The part
numbers are alpha-numeric. When a numeric only part number (mixed in
with
alpha's) is read in, NULL is stored. The routine will read in numeric
values ONLY when all the part numbers in the spreadsheet are numeric.

I've tried formatting the column in the spreadsheet as Text to try and
trick
the routine, with no luck.

Any suggestions? Thanks


Nov 21 '05 #5
Guys... Excuse me for jumping in, but I have exactly Rob T's problem, and
have done what Darrell suggested with success. The integer returned seems to
represent the number of days from a reference day, which I calculated to
12/30/1899. That is, an Excel table cell that contains '7/4/2005' returns
the integer 38537. If your reference date is: dt =
DateTime.Parse('12/30/1899'), then dt.AddDays(38537) is '7/4/2005' which is
correct. But... isn't it a bit odd that 12/31/1899 (the last day of the
century) is not used? Am I missing something? Thanks! Tom Stanley
"Darrell Wesley" wrote:
What your probably seing is the numeric value of the date field , if it is
then all you need to do is convert it back to a date in your VB program.

"Rob T" wrote:
Perhaps I spoke a bit too soon.... that part works, but now all my date
fields are returned as an integer. Any way to convert these back to a date
type?

"Darrell Wesley" <Da***********@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.com...
Take a look at this site:
http://www.connectionstrings.com/

There is another papramer to add in to the connection string to make
certain
Excel treats intermeixed columns as text.

"Rob T" wrote:

> I have a routine that imports a list of part numbers into a dataview:
>
> strExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> boxFile.Text & ";Extended Properties=""Excel 8.0;HDR=NO"""
> cnnExcel = New OleDbConnection(strExcel)
> da = New OleDbDataAdapter("Select * from [ODRJYUFI$]", cnnExcel)
> da.Fill(ds, "Excel")
> dv = New DataView(ds.Tables("Excel"))
>
> This works fine exept when the following condition happens: The part
> numbers are alpha-numeric. When a numeric only part number (mixed in
> with
> alpha's) is read in, NULL is stored. The routine will read in numeric
> values ONLY when all the part numbers in the spreadsheet are numeric.
>
> I've tried formatting the column in the spreadsheet as Text to try and
> trick
> the routine, with no luck.
>
> Any suggestions? Thanks
>
>
>


Nov 21 '05 #6

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

Similar topics

1
by: Richard Holliingsworth | last post by:
Hello: Thanks for your quick response. I'm trying to import a new Excel file into an A2K table and it's truncating the data. One of the Excel columns is a text field that can be up to 2000...
10
by: Arno R | last post by:
Hi all Yesterday I found a strange corruption-issue that I can't solve yet or actually point my finger at. I converted an A97 app to A2k. I have done this often enough so I didn't expect trouble...
1
by: Geoff Jones | last post by:
Hi I have a question which I hope somebody can answer. I have written a VB application with which I want to import an Excel file, analyze the data within it and do some calculations. There are...
2
by: jereviscious | last post by:
Hi all - Last resort time. I'm importing data from a spreadsheet that I receive from one of my vendor using interop.excel. The date field in excel is entered as 4/7/2006, but when I retrieve...
2
by: madeleine | last post by:
I'm hoping the answer to this is that I'm just doing something silly, but I'm really scratching my head over this one. I'm importing data from multiple workbooks, each workbook has a sheet called...
6
by: Michael Peters | last post by:
the Excel data that I would like to import into Access sometimes contain line breaks, like this: 623 749 in one cell. In Access, the imported data looks like this then: 623749
2
by: ScardyBob | last post by:
Hello, I am having trouble importing data from an Excel Worksheet. When I try to import the data, everything works except certain columns that contain dates, where it replaces the date with a...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
0
by: James Minns | last post by:
Hi all, I have a problem with Excel 2007: it crashes when importing certain xml data, exported from another software This is the smallest file which reproduces the problem: <?xml version="1.0"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.