You need to sign in to do that
Don't have an account?
taruna 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.
Any help would be really appreciated.
Thanks in advance.
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,
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!