0

I have requirement where I want to display Excel in viewer instead of downloading it in Salesforce. I am using /sfc/servlet.shepherd/document/download/+ ID to download Excel. Is there any way to open it in browser itself.

  • Could you be more specific. from where you are downloading ? what are you trying to achieve? – Samir Aug 8 at 10:34
0

If you are talking about file and not the attachment, you can do it as follow:-

'/lightning/r/ContentDocument/'+recordId+'/view'

Note:- Use contentdocument id instead of contentversion.

It will open the file detail with preview. If salesforce can not provide the preview it will come as below, else preview will come in preview section.

enter image description here

If you have an attachment, You can view it by using:-

/servlet/servlet.FileDownload?file=attachmentid

Note it will only work for file type that can be preview in Salesforce. You are talking about excel, and they cannot be preview. So everytime it will be downloaded. If it is pdf or image, You can preview it

  • Thank You @sanketKumar for your detailed response. – Vandana Aug 9 at 5:30
  • @Vandana You can accept the answer if has answered your queries. – sanket kumar Aug 9 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.