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
taruna chandwani 8taruna chandwani 8 

Export .xml with an image

Hello, I am exporting .xml file through VF page, but I am unable to get an image on that file. Is there any way to get an image on the file exported. I have tried static resource, document and public url, nothing has worked for me.
Any help would be really appreciated.

Thanks in advance.
VinayVinay (Salesforce Developers) 
Hi Taruna,

Check below reference which has similar issue.

https://stackoverflow.com/questions/62443929/export-excel-in-vf-page-image-not-getting-displayed-while-using-dynamic-image

Thanks,
Suraj Tripathi 47Suraj Tripathi 47
Hi Taruna,

Use contentType in visualforce page like this -
<apex:page controller="TestController" contentType="application/xml">

Consider this example -

Visualforce page-

<apex:page standardController="Account" extensions="attachmentsample">

<apex:form >
 <apex:sectionHeader title="Upload an Attachment"/>
 <apex:pageblock >
 <apex:pageblocksection columns="1">
 <apex:inputfile value="{!myfile.body}" filename="{!myfile.Name}" />
 <apex:commandbutton value="Save" action="{!Savedoc}"/>
 </apex:pageblocksection>
 </apex:pageblock> 
</apex:form> 

</apex:page>

Apex Controller-

public class attachmentsample {

 public attachmentsample(ApexPages.StandardController controller) {

 }
 Public Attachment myfile;
 Public Attachment getmyfile()
 {
 myfile = new Attachment();
 return myfile;
 }
 
 Public Pagereference Savedoc()
 {
 String accid = System.currentPagereference().getParameters().get('id');

 Attachment a = new Attachment(parentId = accid, name=myfile.name, body = myfile.body);
 
 /* insert the attachment */
 insert a;
 return NULL;
 } 
}

Please mark it as the best answer if it helps.
Thank you!
gsd dgsd d
Can you share the complete program sciprt of this page? I want to use it for my website (https://headphonesreviewss.com/best-wireless-headphones-that-look-like-earplugs/).