+ Start a Discussion
Aakash Shivach 6Aakash Shivach 6 

Regarding xls generation through code

I am trying to generate xls through Apex code using VF.
Value we require in the form ex. 012345 bt Xls generate it as 12345.  
So here 0 is not conculded. Our Field 'Bank Acc no' takes value : 0247272 but in xls we get : 247272

Please help
Aniket Malvankar 10Aniket Malvankar 10
Hello Aakash,

This is normal issue faced by a developer in almost every language.
I suggest to format the columne before exporting to XLS.

Thanks
Aniket
Aniket Malvankar 10Aniket Malvankar 10
I would suggested you can manually formate after export in excel
Aakash Shivach 6Aakash Shivach 6
Hi Aniket,

According to our bussiness this xls is being generated by customer and that doesn't sounds good for them to edit it after export.

We should do it through Apex.

Please provide me any answer if you have in relation to apex code, as of what change we can implement to get it done.
Aniket Malvankar 10Aniket Malvankar 10
Hello Aakash,

One thing you can do here is, in your SOQL try converting Bank account in TEXT data type and then try to export in excel.
Since in excel if you pass Bank account as number it is treat the result in number and omits Zero.

Thanks
Aniket
Aniket Malvankar 10Aniket Malvankar 10
Oops sorry 

SOQL itself does not support casting but you can always lend a helping hand ;)

Create a Numeric formula field in SomeObject__c:
IF(ISNUMBER(TextField__c), VALUE(TextField__c), NULL)
Aakash Shivach 6Aakash Shivach 6
Aniket, first one that you said is being implemented but not worthy, but the second one i need to try.

Thanks, i need to set this formula first according to me requirement. Hope it works