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
Sushanth Shetty 7Sushanth Shetty 7 

Download Files from Sales force from backend

Hi 
I was trying to download a file from salesforce 'attachments' object to my local system through sql. I was able to get the files body as 'hexa code' by querying the 'attachments' object. But I am trying to find a way so that I can converts this hexa code into excel file (since the file was a .xlsx file).

Can anyone please help on this.Some other solution is also fine.
Thanks in advance
Ajay K DubediAjay K Dubedi
Hi,
simply query the attachments in your controller
attachmentList=[SELECT Id, Name, Body, ContentType FROM Attachment];
<apex:pageBlockTable value="{!attachmentList}" var="attachCurent" styleClass="table">
<apex:column >
<a href="/servlet/servlet.FileDownload?file={!attachCurent.id}" download="{!attachCurent.name}" style="color:#015ba7;">Download</a>  
</apex:column>
<apex:column value="{!attachmentList.Name}"/>
</apex:pageBlockTable>