1

Unable to open the generated file in OpenOffice unfortunately. My requirement is to generate a ppt file using dynamic data from Salesforce. Here is my snippet of Visualforce Page.

<apex:page controller="TestForPPTController" contentType="application/vnd.ms-powerpoint">
Your PPT Title
    <table border="1px">             
           <apex:repeat value="{!AccountList}" var="a" >
               <tr>
                   <th>Usage</th>
                   <td>{!a.id}</td>
               </tr>
               <tr>
                   <th>Cost</th>
                   <td>{!a.Name}</td>
               </tr>
        </apex:repeat>
    </table>
</apex:page>

Here is my Controller Apex code.

public class TestForPPTController{

    public List<Account> AccountList{get;set;}

    public TestForPPTController(){
        AccountList = [Select id,Name from Account where Id=:'0017F00001Z1fk9'];
    }
}
5

As well as labeling the content that your controller returns as of a specific content-type, you actually have to format the data to match. For PPTX that is a zipped set of XML files, which given that there is no ZIP API available in Apex, would take a lot of work to build (e.g. callouts to an external ZIP service) and careful XML formatting.

Alternatively, you could look for an already existing service that does HTML to PPTX conversion and call out to that.

For PPTX the content-type should be:

application/vnd.openxmlformats-officedocument.presentationml.presentation
  • Thank You for the information @Keith C. Can you please suggest me the reference for the api callouts for the external ZIP serivce. I have done some R&D for the same and I found reference from the microsoft documentation i.e link. But I am unable to find the namescapes to use in XML file. – lavesh galipelli Apr 21 at 9:20
  • 1
    @laveshgalipelli On the XML see e.g. officeopenxml.com/anatomyofOOXML-pptx.php. If you can't find a 3rd party zip services, you would need to write that service using a language that has ZIP support e.g. Java. I would definitely go back to whoever is asking you to do this and explain it is weeks of work and perhaps $5k to $50k of cost. – Keith C Apr 21 at 9:33

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.