Fix Unexpected Leading Zeros When Importing TXT Files into Excel
Question details
The user is experiencing unexpected leading zeros when importing a TXT file into Excel and needs to correctly manage how data types are interpreted during import.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Importing text (.txt) files containing numerical, account, or date data into a spreadsheet.
- Observed behavior
- Leading zeros appear on imported values, which may originate from the raw source file or be affected by Excel's data type interpretation and regional formatting.
Open your original TXT file using a standard text editor (like Notepad) to verify if the leading zeros are already present in the raw data before attempting to adjust Excel's import settings.
Use the Text Import Wizard to Explicitly Set Data Types
Control exactly how Excel interprets each column by forcing specific columns to format as Text or General during the import process.
Excel often tries to automatically detect data types, which can lead to unexpected formatting. Using the Text Import Wizard allows you to define column formats manually, ensuring leading zeros are either preserved as text or correctly dropped as standard numbers.
In Excel, go to the 'Data' tab on the ribbon and click on 'From Text/CSV' (or 'From Text' in older versions). Locate and select your TXT file, then click 'Import'.
Choose 'Delimited' if your data is separated by commas or tabs, click 'Next', and select the specific delimiters used in your source file.
In the Data Preview step, highlight the column containing the leading zeros. Under 'Column data format', select 'Text' to keep the zeros, or 'General' to allow Excel to treat it as a number and drop the zeros. Click 'Finish'.

Transform Data Using Power Query
Use Power Query for advanced data transformation and precise control over column types during the import process.
Verify Windows Regional Settings
Ensure your system's regional settings match the expected format of the imported data to avoid misinterpretation of dates and numbers.
Import and Manage Text Data Seamlessly in WPS Office
WPS Spreadsheet provides a highly intuitive Text Import Wizard, making it easy to correctly format data types, manage leading zeros, and efficiently analyze your TXT and CSV files without hassle.
- 1. Open WPS Spreadsheet: Launch WPS Office and open a new or existing Spreadsheet document.
- 2. Import the TXT File: Navigate to the 'Data' tab on the top ribbon, click on 'Import Data', and select your target TXT file from your local storage.
- 3. Configure the Wizard: Follow the on-screen prompts in the Text Import Wizard. Select your delimiters and apply the 'Text' format to columns where you wish to preserve or manage leading zeros, then confirm to finish the import.

Frequently Asked Questions
Why does Excel normally remove leading zeros upon import?
By default, Excel treats standard digits as numbers. Since leading zeros hold no mathematical value, Excel automatically drops them to format the cell as a standard numerical value unless explicitly instructed to treat the cell as text.
How can I keep leading zeros when manually typing data into a cell?
You can retain leading zeros by typing an apostrophe (') before the number (e.g., '00123). This tells the spreadsheet software to treat the entry as a text string instead of a numerical value.
Can I remove unexpected leading zeros after the data is already imported?
Yes. If the data is imported as text and you want to remove the zeros, you can use the VALUE function (e.g., =VALUE(A1)) to convert the text strings into standard numbers. Alternatively, you can use the 'Text to Columns' feature under the Data tab and set the column format to 'General'.




