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

Downloading csv file from vf page
Hi All,
I am trying to download csv file when i click on button. But when i click button i am getting like this in csv file.
{"index":93 name:"HideProfileElvVideo" value:false}. Below is my code
VF Page:
<apex:page controller="MyCustomListViewController" contentType="application/vnd.ms-excel#filename.csv">{!header}
<!-- <apex:pageBlock >
<apex:pageBlockTable value="{!Contacts}" var="contact" id="pbt">
<apex:column >
<apex:outputField value="{!contact.con.Name}"/>
</apex:column>
<apex:column >
<apex:outputField value="{!contact.con.Account.name}"/>
</apex:column>
<apex:column >
<apex:outputField value="{!contact.con.Phone}"/>
</apex:column>
<apex:column >
<apex:outputField value="{!contact.con.Email}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock> -->
<!-- <apex:repeat value="{!Contacts}" var="contact" >
{!contact.con.Name},{!contact.con.Account.name},{!contact.con.Phone},{!contact.con.Email}
</apex:repeat> -->
<apex:pageBlock >
<apex:pageBlockTable value="{!Contacts}" var="contact" id="pbt">
{!contact.con.Name},{!contact.con.Account.name},{!contact.con.Phone},{!contact.con.Email}
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Please refer the below link to Downloading CSV file from vf page.
- http://salesforce.stackexchange.com/questions/3781/how-do-i-use-visualforce-to-generate-a-csv-file-that-can-be-downloaded-using-ie8
- http://sfdcintegration.blogspot.sg/2015/10/download-csv-file-using-visual-force.html
I Hope it will be helpful.Please mark it as best answer if the information is informative.
Best Regards
Rahul Kumar
Let me know if this helps.
Following piece of code worked for me!
In the same way i did as per my requirement but when i am clicking download button it is downloading VF page only not pageblock table data, i need a file to download as u like .whats the issue?
Plz give a suggestion
regards,
Achyut,
9676961613.
Note:pls give me quick responce if u have possibility...
Visualforce page:
Visualforce controller: