function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
abinayaabinaya 

unable to download xlsx file available in vf page

Hi all,

I am unable to download xlsx files which is available in my vf page in chrome and IE. Kindly help me. 

In my controller i am using this stmt : attachBody = EncodingUtil.base64Encode(itrAttach.Body);

In VF Page : <a download="{!attachItem.attachName}" href="data:{!attachItem.attachContentType};base64,{!attachItem.attachBody}" > {!attachItem.attachName} </a>

Thanks in advance.

Regards,
Abinaya.
Best Answer chosen by abinaya
abinayaabinaya
hi all,

When I used the below in VF Page, I am able to download the files in all the browsers with all file size.

<a href="/servlet/servlet.FileDownload?file={!attachment.id}" download=" {!attachment.name}">{!attachment.name}</a>

Regards,
Abinaya S

All Answers

pconpcon
Where are you getting the contents for itrAttach.Body?  What happens when you click the link to your base64 attachment?
abinayaabinaya
Hi pcon,

I am getting a string for the itrAttach.Body. When i click on the attachment nothing is happening. 

Also this is not only happening for xlsx file. It is happening for all the content type which has greater than 1.5 MB file size.

Kindly let me know your comments.

Regards,
Abinaya S
abinayaabinaya
hi all,

When I used the below in VF Page, I am able to download the files in all the browsers with all file size.

<a href="/servlet/servlet.FileDownload?file={!attachment.id}" download=" {!attachment.name}">{!attachment.name}</a>

Regards,
Abinaya S
This was selected as the best answer
Sai Kumar 449Sai Kumar 449
Hi Abinaya S

I need a small Help from you regarding the xlsx format we are able to do the xls format but i need to get that in the xlsx format can u kindly share me u r code :) 

Thanks 
Saikumar N