Solved

Excel ODBC -- datatype problem

Posted on 2001-08-13
9
400 Views
Last Modified: 2010-08-05
We (I and my coworker) have to import data from brain-damaged Excel sheet with ODBC driver. My coworker managed to find a solution, which unfortunately works only on his PC. The problem is that on his PC one collumn has type 'NUMBER', while on others that column type is 'VARCHAR'.

Any ideas?

0
Comment
Question by:Robson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 22

Expert Comment

by:ture
ID: 6380673
Instead of using ODBC - have you tried opening the Excel workbook in Excel 2002 (Office XP)? This version of Excel is often able to open corrupted documents.

If you don't have Office XP, you may send me the corrupted file and I'll try to fix it for you. If the file is large (more than 1 MB), please zip it before you mail it to me.

My e-mail address is ture@turedata.se

Ture Magnusson
Karlstad, Sweden
0
 
LVL 7

Expert Comment

by:q2eddie
ID: 6380723
Hi, Robson.

#Questions
1. Are you able to edit the spreadsheet?
2. Are you able to change the cell-formatting of its columns?
3. In what version of Excel is this spreadsheet?
4. Could you possibly save it in a different format (such as csv, different version of excel, or dbf)?

5. Exactly how damaged is "brain-damaged"?

#Try This
If Q1 is yes and Q2 is yes, then select the "number" column and goto Format->Cells.  On the "Number" tab, change the category from "number" to either "text" or "general".
Now, see if you can export it.

Bye. -e2
0
 
LVL 4

Author Comment

by:Robson
ID: 6380730
No ture, the file itself is just fine, except it's ill-written: no plain structure, data scattered all over...

My coworker said, that he made some adjustsment, so that datatype defaults to number, not string -- bu he does'nt remember what and where :-(
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:Robson
ID: 6380754
To q2eddie: no problem with manipulating the sheet or saving it to another format (which will be brain-damaged too - the guy who designed that must have been drunk).

The bigger problem is that we are going to recieve this
data every monht in such formatted Excel file: the whole import process must be automated.

0
 
LVL 7

Expert Comment

by:q2eddie
ID: 6380786
Hi, again.

#Questions
1. Into what are you importing it?
2. Do you have any control over how it is imported?
3. Do you use an SQL statement of any type to do the import?
(if yes, could you post a sample?)

#Comment
1. If you are using an SQL statement to do the import, ...

I think that there are supposed to be SQL "functions" that convert numeric fields to text (ex. ToChar ).  These functions can be used in the field clause of the statement.

2. I get the impression that the excel spreadsheets are all going to look like this one.  Hmm...  If you cannot change how the import is handled or how the spreadsheets are originally formatted, then you may need to look at programmatically formatting the spreadsheet before the importing takes place.

Bye. -e2
0
 
LVL 22

Accepted Solution

by:
ture earned 200 total points
ID: 6380807
Robson,

Sorry... I thought "brain-damaged" meant a corrupted file...

To convert a poorly structured workbook to a database or a text file or a well-organized Excel sheet, I would use a VBA procedure that loops through the ranges and worksheets, interprets the original data and writes it in its new format.

I wouldn't use ODBC at all for a task like this.

/Ture
0
 
LVL 4

Author Comment

by:Robson
ID: 6383114
We are importing it to Power Builder application. The SQL statement looks like this (don't laugh):

  SELECT trim(f2),  
         f4  
    FROM "arkusz1$"
     WHERE f4 > 0 and f4 < 999999
UNION
  SELECT trim(f8),  
         f10  
    FROM "arkusz1$"
     WHERE f10 > 0 and f10 < 999999
UNION
  SELECT trim(f14),  
         f16  
    FROM "arkusz1$"
     WHERE f16 > 0 and f16 < 999999
UNION
  SELECT trim("monitory (cyfrowe/mpr ii) :"),  
         netto  
    FROM "arkusz1$"
     WHERE netto > 0 and netto < 999999
UNION
  SELECT trim("c# d#  :  monitory (cyfrowe/mpr ii) :"),  
         netto1  
    FROM "arkusz1$"
     WHERE netto1 > 0 and netto1 < 999999

Take collumn called 'f4' for example. It contains mostly numbers (but some cells contains text). When in a simple SQL interpreter on my coworkers PC you type 'select f4 from "arkusz1$"' you get a collumn of numbers with some blank rows. On others PC you get a collumn of blank rows with several text rows instead... in this case SQL conversion funcions wouldn't work. I suppose that this problem is connected with Excel ODBC driver settings: but we can't see any settings to change.

We would like to avoid any solution that would require modification of original file: anythink should be controlled from our application.

To ture: yes, I agree. I'd rather spend a couple of time to write some code to clean up the original sheet. But we already have an solution -- we only want it to work on every box.


0
 
LVL 4

Author Comment

by:Robson
ID: 6436946
Thanks for your help fellow expers, but I managed to go around the problem by getting a nice formatted text file. Ture's comment seems reasonable, but I'm happy that I don't have to make use of it :-)

Have a nice day!
0
 
LVL 22

Expert Comment

by:ture
ID: 6436963
Robson,

Thanks for accepting my answer even though it wasn't the method you actually used to get the job done.

/Ture
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question