Home › Discussions › Questions & Answers › Preserving Leading Zeros in Excel Output

Preserving Leading Zeros in Excel Output

Avatar photoCustomer Questions & Answers 7 replies

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?

7 replies

  • Support Enginatics

    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` .

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

  • Support Enginatics

    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 .

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

  • Support Enginatics

    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.

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

  • Support Enginatics

    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 .

  • You must be logged in to reply to this post.