Turning off Excel’s automatic number conversions can preserve leading zeros when you open a CSV. It does not apply the same protection to a Power Query import. Microsoft explicitly says the automatic-conversion preferences do not directly affect Power Query, which has its own type rules.
That distinction matters when a product catalog, mailing list or customer export moves between systems. An identifier such as 00123 is a label, not a quantity. Turning it into 123 changes the identifier even though the spreadsheet still looks tidy.
Two import paths, two places to set the type
For direct opening and pasting, Excel’s Automatic Data Conversion controls can stop leading zeros being removed, long digit strings being truncated, and codes such as 123E5 being interpreted as scientific notation. Microsoft lists these controls for Excel for Microsoft 365 and Excel 2024, on Windows and Mac in its guide to keeping leading zeros and large numbers.
On Windows, look under File → Options → Data. On Mac, use Excel → Preferences → Edit. Disable the conversions that would alter your identifiers. The date-like-text option is narrower than a general “never detect dates” switch: Microsoft notes that values containing spaces or separators, such as JAN 1 or JAN-1, may still become dates.
With Data → From Text/CSV, check the types inside Power Query instead. Its automatic type detection is enabled by default for unstructured sources and normally inspects the first 200 rows. It can add a Changed Type step before you have chosen how each column should be interpreted. A plausible preview is not evidence that every value in the file fits that choice.
Keep identifiers as text from the first conversion
Start with an untouched copy of the export, not a CSV that has already been opened, altered and saved in a spreadsheet.
- Choose Data → From Text/CSV, select the file and open the query editor from the preview using Transform Data or Edit, depending on the interface.
- In Query Settings → Applied Steps, inspect Changed Type, if present. Select the step immediately before it to compare the original values. Microsoft’s Applied Steps guide explains how selecting a step shows its result.
- For a fresh import, remove the automatically generated Changed Type step, then explicitly set identifier columns to Text using the type control in each column header. Set genuine quantities and dates separately. In an established query, check downstream steps before removing a conversion they may depend on.
- Check representative values, then choose Close & Load. Keep the query’s explicit types for later refreshes.
Changing a column to Text after a destructive numeric conversion does not reconstruct its original digits. The fix belongs at the step that first interpreted the source, or in a new import of the untouched file.
A small file that exposes the problem
Save this sample as a plain-text CSV and use it to check your chosen import path:
record_id,reference,product_code
00123,12345678901234567890,123E5
00456,12345678901234567891,JAN1
All three columns are identifiers. After importing as Text, the first column must retain five characters, the two references must remain distinct, and the product codes must remain literal text.
The 20-digit references are deliberate. Microsoft documents a 15-significant-digit limit for Excel numbers; formatting a rounded number as Text afterwards cannot restore the missing digits. A custom display format can make a short number look padded with zeros, but that is not the same as retaining the original identifier.
For an independent view of the CSV fields, paste the untouched sample into ToolSprinkle’s CSV to JSON converter with its default settings. It keeps fields as strings, so the first row becomes:
{
"record_id": "00123",
"reference": "12345678901234567890",
"product_code": "123E5"
}
If you export an edited spreadsheet back to CSV, open that new file in a plain-text editor and compare the identifiers with the untouched source. Check the final digits of both references, not just the displayed notation. If they have already changed, recover the values from the original export; adding zeros or changing cell formatting cannot tell you which digits were lost.
