This topic is locked

Include leading 0's on excel export

8/6/2014 3:53:08 PM
PHPRunner General questions
P
p1nr author

Hello,
I found that some values I have that start with a 0 do not show accurately when I export onto excel. I have to change the column to text and manually add the 0's after export. Is there any way to force in leading 0's when exporting in excel?

Sergey Kornilov admin 8/7/2014

This might be Excel trying to auto-detect column type as numeric and hiding leading zeroes.
If you do CSV export and open that file in Notepad - do you see leading zeroes there?

J
jmclain 8/7/2014

I have encountered the same problem as it appears that excel treats any value like 001 to be numeric and strips away the leading 0's.

The way I get around this is I add something like the following to the Export Page/Before Export Record event . . .

$values['YOUR_FIELD']=" ".$values['YOUR_FIELD'];


This will concatenate a leading space to your exported value and excel will treat this as text and will leave the leading 0's intact. I know that this is probably not the most elegant way but it serves my purpose. Hope this helps.