You need to sign in to do that
Don't have an account?

Generate excel file from visualforce without stripping leading 0s
Hello,
I have a visualforce page that i use to generate an excel file which is then sent as an attachment in an email. The problem im having is that one of the columns whenever there is a leading 0 it gets stripped on the output excel file but this 0 is a valid character and i want to keep it. I have tried adding " to the value tag and also using outputtext but if a quote is added (both single and double) then the exported file will contain that quote which is also not a valid.
This is the line causing issues: <apex:column headerValue="DR BSB" value="{!invBSB}"/>
This is the VF page:
I have a visualforce page that i use to generate an excel file which is then sent as an attachment in an email. The problem im having is that one of the columns whenever there is a leading 0 it gets stripped on the output excel file but this 0 is a valid character and i want to keep it. I have tried adding " to the value tag and also using outputtext but if a quote is added (both single and double) then the exported file will contain that quote which is also not a valid.
This is the line causing issues: <apex:column headerValue="DR BSB" value="{!invBSB}"/>
This is the VF page:
<apex:page controller="fundingUI_Excel_Controller" contentType="application/vnd.ms-excel#PPAY.xls" cache="true"> <apex:dataTable var="dt" value="{!dtxns}"> <apex:column headerValue="DR ACLR Code"/> <apex:column headerValue="CR ACLR Code"/> <apex:column headerValue="DR BSB" value="{!invBSB}"/> <apex:column headerValue="DR Account" value="{!invBankAccNum}"/> <apex:column headerValue="Payee Name" value="{!dt.Account_Full_legal_Name__c}"/> <apex:column headerValue="Payee Amount" value="{!dt.Disbursal_Transaction_Amount__c}"/> <apex:column headerValue="CR BSB" value="{!dt.Borrower_Bank_BSB__c}"/> <apex:column headerValue="CR Account" value="{!dt.Borrower_Bank_Account_Number__c}"/> <apex:column headerValue="Payment Type" value="{!paymType}"/> <apex:column headerValue="Narration"> <apex:outputText>Banjo Ref {!dt.Banjo_Loan_No__c}</apex:outputText> </apex:column> <apex:column headerValue="Payment Date" > <apex:outputText value="{0, date, dd'/'MM'/'YYYY}"> <apex:param value="{!TODAY()}" /> </apex:outputText> </apex:column> <apex:column headerValue="Trade Date" > <apex:outputText value="{0, date, dd'/'MM'/'YYYY}"> <apex:param value="{!TODAY()}" /> </apex:outputText> </apex:column> <apex:column headerValue="Settlement Date" > <apex:outputText value="{0, date, dd'/'MM'/'YYYY}"> <apex:param value="{!TODAY()}" /> </apex:outputText> </apex:column> <apex:column headerValue="Asset Code"/> <apex:column headerValue="Units"/> <apex:column headerValue="Brokerage"/> <apex:column headerValue="Broker"/> <apex:column headerValue="Contract Note"/> <apex:column headerValue="Expense Code"> <apex:outputText value="TRANSFER"/> </apex:column> <apex:column headerValue="Transaction type"> <apex:outputText value="FO"/> </apex:column> </apex:dataTable> </apex:page>
<apex:column headerValue="DR BSB" value="{!invBSB}" style="mso-number-format:\@;"/>
you can search google for more of those styles that will control the end result of the cell format type. I do hope this helps someone with the same, very obscure, problem.
All Answers
You may try Text function to convert it to text.
https://sforcehelp.wordpress.com/2016/03/18/convert-number-to-text-on-a-visualforce-page/
Best Regards,
Sandhya
<apex:column headerValue="DR BSB" value="{!invBSB}" style="mso-number-format:\@;"/>
you can search google for more of those styles that will control the end result of the cell format type. I do hope this helps someone with the same, very obscure, problem.