Home Discussions Questions & Answers Preserving Leading Zeros in Excel Output

Preserving Leading Zeros in Excel Output

Avatar photoCustomer June 9, 2025 at 12:01 pm

We have alphanumeric data, such as serial numbers (e.g., ‘00123’), that loses its leading zeros when exported to Excel because Excel interprets it as a numeric value. How can I modify the SQL query to force Excel to treat these columns as text, preserving the leading zeros?

Viewing 6 reply threads
  • Author
    Replies
    • Support June 9, 2025 at 8:31 pm  

      To prevent Excel’s automatic type detection from treating alphanumeric data with numeric content as a number, you must explicitly format the column output in the SQL to enforce text formatting . The workaround involves prefixing the column data with an equal sign and enclosing it in double quotes . The SQL should look like this: `’=”‘ || cii.serial_number || ‘”‘ serial_number` .

    • Avatar photoCustomer June 10, 2025 at 2:59 am  

      If I use this workaround, will the output file still contain the extra characters (`=”` and `”`) when opened in Excel?

    • Support June 10, 2025 at 9:17 am  

      No, if you apply this specific SQL workaround and run the report in the recommended XLSX output format, Blitz Report is designed to automatically remove the redundant prefix (`=”`) and suffix (`”`) characters from the data upon generation . This ensures the content displays correctly as alphanumeric text in Excel .

    • Avatar photoCustomer June 12, 2025 at 6:50 am  

      Does this technique also apply if I output the file in CSV format?

    • Support June 12, 2025 at 10:49 am  

      The documentation specifies that the automatic removal of the prefix/suffix characters (`=”` and `”`) occurs when the report is run in XLSX output format . While CSV format also preserves alphanumeric data, the specific automated cleaning process is noted for the XLSX format . If using CSV, you should verify if the raw CSV output still retains the extra quotes/equals signs.

    • Avatar photoCustomer June 12, 2025 at 8:12 pm  

      Is there a default maximum column width set for XLSX output files?

    • Support June 14, 2025 at 2:30 am  

      Yes, the maximum column width for Blitz Report XLSX output files is controlled by the profile option ‘Blitz Report XLSX Max Column Width’ . The default maximum column width is 60 .

Viewing 6 reply threads
  • You must be logged in to reply to this post.

Login with: