I created a sub which reads all the sheets from an Excel .xlsx workbook into seprate DataTables in a DataSet using the Microsoft.ACE.OLEDB.12.0 data provider.
Now, I have one workbook with multiple sheets – All of which have the same column names – and what I’m trying to do is, once they are all loaded into the dataset, to merge them all into one large DataTable.
My problem is that even though all the sheets have the same columns, based upon the data in each sheet, sometimes the same columns get a Double Data Type and other times they get a String Data Type in the different tables of the DataSet, so, the Merge function is giving me an error.
How can I fix this? Is there a way to set the Column datatypes ahead of time to all be string or is there a way to ignore column-type while merging or is there a better way to solve this altogether?
Thanks.
I have worked with this before.. I’m trying to go mostly from memory. There is a registry entry called TypeGuessRows that you can set. This will disable guessing the type for Excel.
Additionally, try adding the IMEX argument in your ACE connection string.
Other side note: This is probably a duplicate question.
Edit:
From Google, the registry location: http://support.sas.com/kb/31/765.html
Another SO Helpful post: Reading Excel InterMixed DataType Without Modifying Registry Key