You need to sign in to do that
Don't have an account?
JustAGirlyGeek
Exporting to Excel in Lightning
In Classic, you can create a simple Visualforce page to export records to Excel using contentType. For example:
I need this to work in Lightning but I am hitting a roadblock with getting this to work right. If I use a custom button to call the VF page, the export works, but leaves me with a blank screen instead of taking me back to the record where I clicked the button. If I use a Quick Action to call the VF page, it still works, but now leaves me with a modal and the only option is to click Cancel.
What are my other options here? I am not a developer so my skills are a bit limited. TIA!
<apex:page StandardController="Opportunity" contentType="application/vnd.ms-excel#export_{!NOW()}.xls"> <apex:pageBlock title="Export Results"> <apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="item"> <apex:column value="{!item.PricebookEntry.Name}"/> <apex:column value="{!item.PricebookEntry.ProductCode}"/> <apex:column value="{!item.Description}"/> <apex:column value="{!item.ServiceDate}"/> <apex:column value="{!item.Quantity}"/> <apex:column value="{!item.Sales_Price__c}"/> <apex:column value="{!item.TotalPrice}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
I need this to work in Lightning but I am hitting a roadblock with getting this to work right. If I use a custom button to call the VF page, the export works, but leaves me with a blank screen instead of taking me back to the record where I clicked the button. If I use a Quick Action to call the VF page, it still works, but now leaves me with a modal and the only option is to click Cancel.
What are my other options here? I am not a developer so my skills are a bit limited. TIA!
My strange solution seems to work but the trick is used just for closing the "Quick Action" popup ( $A.get("e.force:closeQuickAction")).
Controller: the toast is used for nice messages in LEX.
opportunityxls.vfp (your code):
Regards
Thank you! I will give this a try.
It will be interesting to export a big list in the excel files (not tested).
If you find another alternative, could you also post it here? (alternative for the iframe for example).
Sending the Message in the Lightning Component: also uses the iframe.
https://developer.salesforce.com/blogs/developer-relations/2017/01/lightning-visualforce-communication.html