XLSX Data Types: Preserving Leading Zeros, Dates and Long Numbers

November 08, 2026 · XLSX.now Editorial · XLSX Troubleshooting

Explain cell types, number formats, locale parsing and round-trip checks beyond CSV.

How XLSX Stores Cell Values

Every cell in an XLSX file holds up to three pieces of information inside the sheet XML (xl/worksheets/sheet1.xml):

  • Value: the raw datum, such as 1234 or the string "001234"
  • Type attribute: s (shared string), n (number), b (boolean), e (error), or absent (defaults to number)
  • Style reference: an index into styles.xml that points to a number format mask and display properties

This separation is defined in the Office Open XML Standard, Part 1, §18.3.1. A cell is never simultaneously "a number that looks like a date" and "a number that looks like text." It is always one type with an optional format mask applied by the application layer (Excel, LibreOffice, Google Sheets). Disagreement between what you see and what is stored comes from the application interpreting that mask differently than you expected.

Inspecting the Raw Storage

  1. Rename the .xlsx file extension to .zip and open the archive.
  2. Navigate to xl/worksheets/sheet1.xml.
  3. Locate a <c> element.
    <c r="A1" s="0" t="s"><v>0</v></c>
    Cell A1 uses shared string index 0. The actual text lives in xl/sharedStrings.xml.
  4. Compare with:
    <c r="B1" s="1"><v>45292</v></c>
    No t attribute means numeric type. The value 45292 is a date serial number. Style index 1 in styles.xml contains the format mask that tells the application to display it as a date.

If you cannot unzip the file, open it in a plain-text editor capable of reading binary streams (Notepad++ or VS Code). Search for <c r= to find cell definitions. This confirms whether a value with leading zeros is stored as a string or a number.

Leading Zeros and the String-or-Number Decision

When you type 001234 into a cell with the default "General" format, Excel strips leading zeros and stores 1234 as a number. Three input methods force string storage:

  • Prefix the entry with a single quote: '001234
  • Pre-format the column as Text (Home → Number → Text) before entering data
  • Import via the Text Import Wizard and mark the column as text

Observable Failure Modes

CSV round-trip loss. A CSV file has no type metadata. The string 001234 in a CSV becomes the number 1234 when Excel opens it with default settings, because the General format triggers numeric coercion. Saving that workbook as XLSX permanently stores 1234 as a number. Re-exporting to CSV writes 1234 with no quotes.

Formula incompatibility. A formula referencing a text-stored value behaves differently from one referencing a number. =A1+1 on a cell containing the string "001234" returns #VALUE!. The string is visually intact but computationally inert.

Precision truncation on long numeric IDs. Excel's numeric precision is 15 significant digits (IEEE 754 double-precision). A 17-digit product ID such as 98765432109876543 stored as a number becomes 98765432109876544. The only way to preserve all digits is to store the value as text.

Verification Procedure

  1. Format the target column as Text before entering any data.
  2. Enter 001234.
  3. Save as XLSX and close the file.
  4. Re-open the file. If 001234 still displays, inspect the XML as described above and confirm t="s" or t="inlineStr" on the cell.
  5. Export to CSV from the application. Open the CSV in a plain-text editor. The value must appear as "001234" (quoted). If it appears as 1234 without quotes, the XLSX stored it as a number.

Dates and Times as Serial Numbers

Excel stores dates as the number of days since January 0, 1900, with the Lotus 1-2-3 leap-year bug preserved for compatibility. Time is a fractional day. The value 45292 represents May 1, 2024. The value 45292.5 represents noon on that day.

The XLSX format mask in styles.xml controls display. Common masks include:

  • m/d/yy → 5/1/24
  • yyyy-mm-dd → 2024-05-01
  • h:mm:ss → 12:00:00

Locale-Dependent Parsing

When an XLSX opens on a system with a different locale, the application may reinterpret ambiguous date strings. 1/2/2024 is January 2 in a US locale (mm/dd/yyyy) and February 1 in a German locale (dd/mm/yyyy). The internal serial number is identical regardless. Only the display changes based on the locale-aware format mask. If you manually typed 1/2 and Excel interpreted it as a date, the stored serial number is fixed. Exporting to CSV produces 1/2/2024 or 2/1/2024 depending on the export locale, but the serial number itself does not change.

What Conversion Cannot Recover

Date-only vs. datetime ambiguity. A cell with value 45292 and format m/d/yy displays as a date. A cell with the same value and format m/d/yy h:mm displays midnight. Both are the identical number. Once exported to CSV as 45292, the original display intent is lost.

Loss of relative date functions. Functions such as TODAY() or NOW() are stored as their computed serial number at save time, not as formula references. The XLSX file contains a static number and does not recalculate to the current date when reopened.

Two-digit year window. Entering 1/1/30 in Excel interprets the year based on a sliding window (typically 1930–2029 maps to the 20th century). The XLSX stores the full serial number for January 1, 1930. A different application using a different window may interpret the same serial number as a different year.

Long Numbers and the 15-Digit Precision Limit

The XLSX specification does not impose a precision limit. IEEE 754 double-precision floating point does. Exactly 15 decimal digits are guaranteed. Beyond that, rounding occurs:

  • Input: 12345678901234567 (17 digits)
  • Stored value: 12345678901234568 (last two digits are rounding artifacts)
  • Re-displayed: 12345678901234568 or 1.23457E+16 in scientific notation

Mitigation Options

  • Store as text. Pre-format the column as Text. The value is stored as a string and survives round-trips. Arithmetic on that cell becomes impossible.
  • Custom number format. A mask such as 0 forces display of all digits, but the underlying value is still truncated. The visual shows 12345678901234568 while the true input is lost.
  • Split across columns. For identifiers that must remain exact (credit card numbers, IMEI codes), split into two columns of 8–10 digits each and concatenate for display.

Round-Trip Verification

  1. Enter a 17-digit number in a cell formatted as Text.
  2. Save, close, and reopen the file. The displayed value must match the input exactly.
  3. Change the cell format to Number or General. The value may now round.
  4. Open the file in a different application (LibreOffice Calc or Google Sheets). If the number changes from the original input, the XLSX stored it as a number, not text.

Display vs. Storage: A Reference Table

Displayed Value Stored Value (XML) Cause
001234 1234 (number) Leading zeros stripped by numeric coercion
5/1/24 45292 (number) Date serial number with format mask
$1,234.56 1234.56 (number) Currency format mask applied
1.23E+03 1234 (number) Scientific notation format mask
50% 0.5 (number) Percentage format mask

The only way to confirm the stored type is to inspect the XML directly or use a tool that exposes the cell type attribute alongside the formatted display.

Diagnostic Workflow for Received Files

When you receive an XLSX and need to verify data integrity:

  1. Identify a cell that should contain leading zeros or a long numeric ID. Note its displayed value.
  2. Export to CSV using a tool that exposes raw values, not the formatted display. Many converters offer a "raw values" mode that writes date serial numbers and full-precision numbers.
  3. Compare the CSV output to the expected input. If the CSV shows 45292 where you expected 5/1/24, the XLSX stored a date serial number. If the CSV shows 1234 where you expected 001234, the XLSX stored a number.
  4. Open the XLSX in a different application (LibreOffice Calc or Google Sheets). If the display changes, the original application applied a format mask that the new application interprets differently. The underlying stored value has not changed, but the mask is no longer producing the expected visual result.