?
Solved

Excel ODBC -- datatype problem

Posted on 2001-08-13
9
Medium Priority
?
411 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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

800 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