Page 1 of 1

Losing leading Zeroes during Excel Download

Posted: Tue Dec 19, 2023 4:55 pm
by aspsteve

I have some reports which contain some account numbers with leading zeros.

I lose those leading zeros when I download the output to Excel.

Is there anything that can be done about this?


Re: Losing leading Zeroes during Excel Download

Posted: Wed Dec 20, 2023 8:36 am
by MichaelG

Microsoft Excel may format numbers automatically by removing the leading zeroes. You can format the number first in the Row_Rendered server event by adding a leading single quote. For example:

if (IsExport("excel")) {
    Field.ViewValue = "'" + Field.ViewValue; // Prevent formatting by excel
}