Ask a Question related to Coldfusion Database Access, Design and Development.
-
cmkelly #1
Leading Zeros not being read from Excel Query
We are having an odd problem when trying to read in a query from Excel.
What we are trying to do: We have a page where users will upload an Excel file
through a form, we make a copy of the file on the server and then try to read
in that data to write to our database.
Our Problem: Our CFQUERY reads almost everything correctly. The only problem
is that one of the fields in the Excel file contains a nine digit number (SSN).
This nine digit number will sometimes contain leading zeros (ex. 012345678). In
excel, if the cell is a number, it tries to strip the leading zeros. If you
change the cell to a text field, it displays in excel exactly the way it was
typed in. However, a CFDUMP of our query reveals that those numbers that start
with a zero, comes in as "empty string".
What we have tried: We have tried putting in alphanumeric strings that start
with zero (ex. 0ABCD) with the same result. We tried changing the formatting in
excel to a special/custom type which only changed the display in Excel. We
tried saving the file out as various versions (95, 97, etc.).
Has anybody else had this problem or have any ideas??
cmkelly Guest
-
Disappering leading zeros
Have a problem that has me swinging. I have a MS Access d/b that contains a zip code directory. Updates are done via a web-based ColdFusion form.... -
CSV file - Leading Zeros
Is there a way to write a CSV file so that excel wont drop the leading zero's from fields? I could use spreadsheet::writeexcel or OLE but that's... -
missing strip function in DB2 8.1 -- remove leading zeros
sujit <yhkumars@yahoo.com> wrote: Where did you have the STRIP function? It didn't exist in version 7.... -
Insert leading zeros
I have a string of digits that looks like something like these: 0025, 1234, 0001, 1003, and so on. They are all 4 digits in length. Then when I... -
CSV for Excel - Problem with Leading Zeros
Can we consider change the string to: ' 0000563' ? Luke (This posting is provided "AS IS", with no warranties, and confers no rights.) -
mxstu #2
Re: Leading Zeros not being read from Excel Query
That is an old issue with querying excel files that goes way back. If you
search the old forum archives for EXCEL there are many posts on this topic. If
you cannot access the archives through this site, you might want to try
searching through google groups instead.
The basic problem is caused by how the driver determines the column data
types. When you query a database table, each column has a single, known, data
type. When you query an Excel file, the spreadsheet columns do not have data
types. The driver has to guess each column's type by using the values in that
column. Sometimes it guesses correctly and other times it doesn't.
These links do not refer to cfquery, but the do describe the problem
[url]http://support.microsoft.com/default.aspx?scid=kb;en-us;257819[/url]
There were a number of suggested work arounds, such as:
- Setting the column in excel to type text and re-pasting the values
- Setting the "rows to scan" value
- Using a setting called IMEX
- Saving the work sheet as a text file and using a "schema.ini" file when
reading in the file
I don't remember the specifics about which method... if any of them ...
actually worked, but this may at least give you somewhere to start looking.
Good luck
mxstu Guest
-
belie #3
Re: Leading Zeros not being read from Excel Query
This is an old topic but here's how I was able to solve it (my problem was with
zip codes starting with a 0 and some of the data being 10 digit zip codes):
select * from `sheet_name_here$` IN 'C:\SomeDirectory\myfile.xls' 'EXCEL
5.0;IMEX=1'
the 'EXCEL 5.0;IMEX=1' forced everything to be a string i believe.
belie Guest



Reply With Quote

