Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i show the leading zeros when exporting to excel?

Tags:

excel

vbscript

I am creating an excel report by changing the content type.

Response.ContentType = "application/vnd.ms-excel"

I have values that contain leading zeros. The issue is when exporting to excel the leading zeros are missing.

e.g.

000123 -> 123

I know that this can be changed manually via excel. The question is how can i accomplish this programmatically?

like image 329
Tesseract Avatar asked Dec 14 '22 03:12

Tesseract


1 Answers

Ive found the answer, you can surround the value in quotes and prefix it with an equals sign to preserve the leading zeros.

="000123"

See here: Excel vs. Leading Zero & Space

like image 193
Tesseract Avatar answered Jan 09 '23 09:01

Tesseract