A CSV file will retain leading zeros when opened with text-type apps such as Notepad, Sublime, or TextEdit. However, both Excel and Google Spreadsheet will remove leading zeros after saving the file, unless formatted as described below.
This is an Excel/Sheets feature, Salesforce does not control this functionality. Below are steps that can be taken to restore the leading zero in the file so an import into Salesforce has the expected values.
Please note that the steps listed below are just one example of how to use a custom field in Excel to display the leading zero. For more methods on retaining leading zeros, please visit the Microsoft support page.
1. Once you open the CSV file, right-click the column letter and select Format Cells.
2. In the Format Cells window, choose Custom. Set the format to '00000000' for example to represent a field of length 8. The number of 0's should indicate the number of characters desired in the field, including the 0's. If the field value is 012345, then the custom format should be '000000' to indicate 6 digits with the 0.
3. Save the file as a .CSV.
Note: The above steps are just one way to have the leading zeros display in Excel. These steps need to be implemented every time the CSV file is reopened in a spreadsheet program like Excel. Opening the CSV with a text editor like Notepad or macOS TextEdit.app will show the leading zeros.
For more information on the different ways to format fields to keep leading zeros in Excel or GoogleSheets, please visit the Microsoft or Google websites for more information.
000387891

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.