+ Start a Discussion
Peter BoelkePeter Boelke 

How to use Quick action for export?

Hello,

i need a quick action button to export contact data as csv. I have created a visualforce page which is related to a quick action button. But it doesnt really work proper.
In Classis it shows the cvs-data on the page. In Lightning is just start the download of the file. I want to start the download only if the quick action button is clicked. How can i achiev this?

VF-Page
<apex:page standardController="Task" extensions="CtrlContactExport" contenttype="application/vnd.ms-excel#Export_Contacts.csv">RNAME1;RNAME2;RSTREET;RHHOUSENO;RPOSTAL;RCOUNTRY;RPHONE;REMAIL
    <apex:repeat value="{!list_contacts}" var="c" >
"{!c.Name}";"{!c.Salutation}";"{!c.MailingStreet}";"{!c.MailingStreet}";"{!c.MailingPostalCode}";"{!c.MailingCountry}";"{!c.Phone}";"{!c.Email}"
    </apex:repeat>
</apex:page>
Controller
public class CtrlContactExport {
    
    public list<Contact> list_contacts {get;set;}
    
    public CtrlContactExport (ApexPages.StandardController controller){

        exportContacts();
        
    }
    
    public Pagereference exportContacts(){
        list_contacts = [SELECT Name, Salutation, MailingStreet, MailingPostalCode, MailingCity, MailingCountry, Phone, Email FROM Contact];
        return new Pagereference('');
        
    }
 
}

Thanks for advice
Peter
 
Ashif KhanAshif Khan
Hi Peter,
This is a blog post for export data in lightning on button click.
you can create your excel file by directly calling <aura:handler init

http://sfdcmonkey.com/2017/04/19/download-csv-file-data-salesforce-lightning-component/

and use this component on quick action button.
Regards 
Ashif