I'm trying to read all the data as string and then I convert it to proper datatype.
it shows "3.2240411747e+011" as text instead of "322404117474"
To a large extent, this issue can by mitigated by constructing the SQL select statement to format the string created by the ACE provider. There appears to be an error in way the provider determines significant figures when it converts a Double to a String.
A Double can hold up to 15 significant figures. The value "322404117474" is 12 digits long, but its string representation "3.2240411747e+011" only has 11 digits. What I believe is happening is that four character positions taken up by the signed exponent are falsely being considered significant. This appears to only be an issue for cells having the default "General" format with an integer part more than 11 digits long. If the cells have a number format applied to them, the accuracy displayed by that format will be used. Therefore, you should expect loss of accuracy when importing the values as strings.
However, before I go into the SQL statement, I want to address the inclusion of TypeGuessRows=0
in the Extended Properties section of the connection string.
Simply put, this wrong. The TypeGuessRows value is always read from the registry. For a dated but good write-up on the parameter, see: External Data – Mixed Data Types.
You do not show the SQL statement you are using, but in its simplest form it would look like:
Select * From [sheetName$]
This wildcard "Select" is problematic when trying to read the field values as strings. If the field is a mixed numeric/string column that is reinterpreted as string, the retrieved strings will formatted in accordance with the cell formatting.
Assume the Worksheet being retrieved looks like this:

Rows 1, 2, and 4 contain numeric values. Row 5 is a number entered as text and Row 3 is obviously text. When this is retrieved using the above SQL (and HDR=NO
) then and displayed in DataGridView, the result is:

The retrieval of values format this way can be an obvious problem if you need to parse them back to a numeric type.
When using the Jet or ACE OleDB provider to read Excel files, you can use several VBA functions that are available in MS Access in the SQL query. If the VBA Format Function is used in the Select statement like this:
Select F1, Format(F2) As F2 From [sheetName$]
The the retrieved values will look like this:

The field names "F1" and "F2" are automatically assigned by the provider when there is no header row specified to provide the names. The numbering is sequential from 1 to the number of columns found in the table.