How to Preserve Leading and Trailing Zeros in Excel IQY Imports
Question details
The user needs to prevent leading and trailing zeros from being removed or altered when importing data into Excel using an Internet Query (IQY) file.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Importing web-based or database data via an IQY file where certain numeric fields (like IDs or codes) require exact formatting preservation.
- Observed behavior
- Excel automatically interprets the imported data as numbers, which strips away leading zeros and occasionally alters trailing zeros due to its 15-digit precision limit.
Before beginning, check if you have edit access to the database or the server-side script generating the IQY file, as modifying the source output is often the most reliable way to prevent formatting loss.
Modify Source Data with an Apostrophe Prefix
Force Excel to treat the incoming IQY data as text by prefixing numeric values with an apostrophe at the source generation level.
Excel natively converts strings containing only digits into numeric values. By adding an apostrophe before the number in the raw data, Excel will recognize the cell as text, preserving all zeros without displaying the apostrophe in the worksheet.
Access the backend script, SQL query, or application that generates the data feed for your IQY file.
Identify the specific database columns or fields that contain numbers requiring leading or trailing zeros (e.g., account numbers or product codes).
Modify the code to concatenate an apostrophe (') at the very beginning of the string for those specific output fields.
Save your changes and open the IQY file in Excel again. The values will now load cleanly as text, maintaining all zeros.

Use Power Query for Advanced Import Control
Bypass the traditional IQY direct import method and use Excel's Power Query feature to explicitly define data types before loading them into your worksheet.
Seamlessly Import and Format Data in WPS Spreadsheet
WPS Spreadsheet provides powerful external data import utilities that let you specify column formats upfront. By explicitly defining columns as text during the import process, you can effortlessly preserve leading zeros and exact numeric precision.
- 1. Open WPS Spreadsheet: Launch WPS Office and open a new or existing spreadsheet document.
- 2. Initiate Data Import: Navigate to the 'Data' tab on the top ribbon and select 'Import Data' to connect to your external data file.
- 3. Configure the Wizard: Proceed through the initial steps of the text import wizard until you reach the 'Column data format' configuration screen.
- 4. Format Column as Text: Highlight the specific column containing the numbers in the data preview pane, then select the 'Text' radio button.
- 5. Finish and Load: Click 'Finish' to successfully load your external data with all original formatting and zeros flawlessly preserved.

Frequently Asked Questions
Why does Excel automatically remove leading zeros during an import?
By default, Excel analyzes incoming data to determine its type. If a column contains only digits, Excel automatically converts it to a numeric data type, which mathematically drops any non-significant leading zeros.
What is Excel's 15-digit precision limit?
Excel conforms to the IEEE 754 specification for storing floating-point numbers, meaning it can only store up to 15 significant digits accurately. Any digits past the 15th decimal place are automatically converted to trailing zeros unless the value is specifically imported and stored as text.
Can I format the cells as text after the IQY import to bring the zeros back?
No. Formatting cells as text after the import has already occurred will not restore the dropped leading zeros. You must ensure the data is recognized as text during the initial import process itself.




