samuel-alves
3/2/2018 - 10:20 AM

Save to CSV/Excel

Save to CSV/Excel in visual force with UTF 8 chracters

References: https://developer.salesforce.com/forums/?id=906F0000000962nIAA

<apex:page controller="MyCustomController" cache="true" contenttype="application/x-excel#filename.xls" showheader="false">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
</head>
	<apex:pageBlock >
	    <apex:pageBlockTable value="{!allRecords}" var="line" columns="3">  
          	<apex:column headerValue="Col A">{!line.fieldA}</apex:column>
          	<apex:column headerValue="Col B">{!line.fieldB}</apex:column>
          	<apex:column headerValue="Col C">{!line.fieldC}</apex:column>
		</apex:pageBlockTable>
	</apex:pageBlock>
</apex:page>