<p>I'm able to connect to and read an excel file no problem.  But when importing data such as zipcodes that have leading zeros, how do you prevent excel from guessing the datatype and in the process stripping out leading zeros?</p>

[{'answer_id': 22891, 'author': 'Stu', 'author_id': 414, 'author_profile': 'https://Stackoverflow.com/users/414', 'pm_score': 1, 'selected': False, 'text': "<p>Prefix with '</p>\n"}, {'answer_id': 22897, 'author': 'Owen', 'author_id': 2109, 'author_profile': 'https://Stackoverflow.com/users/2109', 'pm_score': 1, 'selected': False, 'text': "<p>Prefixing the contents of the cell with ' forces Excel to see it as text instead of a number.  The ' won't be displayed in Excel.</p>\n"}, {'answer_id': 22900, 'author': 'Krantz', 'author_id': 2528, 'author_profile': 'https://Stackoverflow.com/users/2528', 'pm_score': 0, 'selected': False, 'text': '<p>I think the way to do this would be to format the source excel file such that the column is formatted as Text instead of General. Select the entire column and right click and select format cells, select text from the list of options.</p>\n\n<p>I think that would explicitly define that the column content is text and should be treated as such.</p>\n\n<p>Let me know if that works.</p>\n'}, {'answer_id': 22908, 'author': 'palehorse', 'author_id': 312, 'author_profile': 'https://Stackoverflow.com/users/312', 'pm_score': 4, 'selected': True, 'text': '<p>I believe you have to set the option in your connect string to force textual import rather than auto-detecting it.</p>\n\n<pre><code>Provider=Microsoft.ACE.OLEDB.12.0;\n    Data Source=c:\\path\\to\\myfile.xlsx;\n    Extended Properties=\\"Excel 12.0 Xml;IMEX=1\\";\n</code></pre>\n\n<p>Your milage may vary depending on the version you have installed.  The IMEX=1 extended property tells Excel to treat intermixed data as text.</p>\n'}, {'answer_id': 22926, 'author': 'TheEmirOfGroofunkistan', 'author_id': 1874, 'author_profile': 'https://Stackoverflow.com/users/1874', 'pm_score': 0, 'selected': False, 'text': "<p>Saving the file as a tab delimited text file has also worked well.</p>\n\n<p>---old\nUnfortunately, we can't rely on the columns of the excel doc to stay in a particular format as the users will be pasting data into it regularly.  I don't want the app to crash if we're relying on a certain datatype for a column.</p>\n\n<p>prefixing with ' would work, is there a reasonable way to do that programatically once the data already exists in the excel doc?</p>\n"}, {'answer_id': 677697, 'author': 'cjk', 'author_id': 52201, 'author_profile': 'https://Stackoverflow.com/users/52201', 'pm_score': 1, 'selected': False, 'text': '<p>There is a registry hack that can force Excel to read more than the first 8 rows when reading a column to determine the type:</p>\n\n<p>Change</p>\n\n<pre><code>HKLM\\Software\\Microsoft\\Jet\\4.0\\Engines\\Excel\\TypeGuessRows \n</code></pre>\n\n<p>To be 0 to read all rows, or another number to set it to that number of rows.  </p>\n\n<p>Not that this will have a slighht performance hit.</p>\n'}, {'answer_id': 20784334, 'author': 'Rajans', 'author_id': 3136602, 'author_profile': 'https://Stackoverflow.com/users/3136602', 'pm_score': 0, 'selected': False, 'text': '<p>Sending value <code>00022556</code> as <code>\'=" 00022556"\'</code> from Sql server is excellent way to handle leading zero problem</p>\n'}, {'answer_id': 29393654, 'author': 'zoobiezoobie', 'author_id': 4596997, 'author_profile': 'https://Stackoverflow.com/users/4596997', 'pm_score': 0, 'selected': False, 'text': '<p>Add "\\t" before your string. It\'ll make the string seem in a new tab.</p>\n'}]
['https://Stackoverflow.com/questions/22879', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1874/']