Importing Excel errors, ODBC and schema.ini

2019-09-12 07:24发布

问题:

How can you overcome importing excel file errors? When the datatype is incorrectly determined it is because enough of the file has not been scanned.

txt and csv files you can set a schema.ini and/or have the whole file scan to the end. This MSDN reference says

MAXSCANROWS The number of rows to be scanned when setting a column's data type based upon existing data. A number from 1 to 16 can be entered for the rows to scan. The value defaults to 8; if it is set to 0, all rows are scanned. (A number outside the limit will return an error.) This sets the same option as Rows to Scan in the setup dialog box.

If I set the rows scanned to 0 an error is thrown saying "Invalid rows to scan" After re-reading this, I see the range is between 1-16 and since 0 is outside that range I can't get a complete scan, as I could with a csv or txt file.

The issue is when importing sku ids for clients, some data appearing numeric at the top of a file causes a misinterpretation of the datatype. If a schema.ini could be used on excel files that would be wonderful. Is there no way to overcome this short of looping through every cell and wrapping the string in ""?

回答1:

If you are able to convert the file to csv, you will have an easier time importing it using the 'Suggest Types' feature which allows you to scan through x rows in your file and pick the most appropriate data type for each column.