Hello,
I'm looking to output a PowerPoint using a PowerPoint template depending on different projects.
Only a few fields will be updated in the PowerPoint slides based on upstream data.
I thought about using a reporting tools, but it seems like I cannot input a PowerPoint as a template input file, so modifying XML file would be a better choice in Alteryx.
There was a similar conversation in the Alteryx community forum: https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Auto-populate-powerpoint-template-with...
If I'm understanding it correctly, this approach is to:
1. extract the PowerPoint to xml first
2. modify the xml file in Alteryx using the upstream data
3. Alteryx will produce the modified XML file, not PowerPoint
4. use the modified XML for different projects
I tried to follow what they've done using the XML input file, so I used a 7zip to extract the PowerPoint and it produced many xml files. However, I was not sure which XML file was the one that contained actual content in the slide deck to modify. Does anyone know which one to use? Also, if there is a better way to accomplish this, I appreciate any inputs!
Sincerely,
knozawa
Solved! Go to Solution.
Hi, @knozawa - the XML files you want to edit are in the ppt --> slides folder. Inside \ppt\slides, you'll find a separate XML file for each slide in your presentation (slide1.xml, slide2.xml, etc.)
I use this method myself, and it works well. I'll be interested to see if there are other ideas for accomplishing this!
The general method is:
Thank you for your detailed reply!
I followed your instruction and have questions:
Q1. When you replaced the value, did you replace whole thing {{open_roles}} to sales for example (meaning the {{}} will be removed in the modified xml file)?
Q2. At the last step, did you re-zip the whole folder that contained all the xml files using 7zip or just compressed (zipped) folder from the file explorer directly? I tried both ways and changed the .zip to .pptx. When I tried to open the PowerPoint, it showed an error message:"PowerPoint found unreadable content in ...There was an error accessing...".
Q1 - Correct - replace the whole thing, including the brackets, like replace([your_xml_field], "{{sales}}", tostring([your_sales_field]))
The curly brackets are there to identify the placeholders in your template vs. other text in your template. For example, the word "sales" could occur in the title of your slide, so you don't want to replace that. We only want to replace sales when it is surrounded by curly brackets.
Q2 - correct, zip all of the files (including [Content Types].xml) into a new zip file, and make sure that the folder structure (_rels, customXml, etc.) is present in your zip file.
I haven't tried using 7zip to create the zip file, but I don't see any reason why that wouldn't work. I'm using Python zipfile to create my zip file, but I have also done it manually from the File Explorer, which also works.
One other issue that could cause that error is when the replacement text has certain characters in it (XML predefined entities, such as & " ' < >). You will need to replace those with their name (e.g. "&" for ampersand or "<" for <).
For example, say you have the placeholder {{department_name}}, and the actual department_name is Planning & Analytics. Inserting Planning & Analytics in the XML will cause an error due to the ampersand (&). You can fix it by replacing the & with the character name, "&"
Example: replace([your_xml_field], "&", "&")
It will appear as "Planning & Analytics" in the raw XML, but it will appear as "Planning & Analytics" in PowerPoint.
Two other things to check:
If you're still having issues, please share an example of your workflow with some fake data, as well as your .pptx template, so we can take a look at what might be happening!
@kelly_gilbert
Thank you for your help! I still have issue opening the corrupted PowerPoint.
I wanted to attach the PowerPoint and Zip folder, but it seems like there is a restriction on uploading those file types in the Alteryx Community forum.
Here is the screenshot:
1. original PowerPoint ("DELETE.pptx")
2. {{delete}} was updated to DELETEDELETE in slide1.xml
3. The DELETE zipped folder's extension was updated to .pptx ("DELETE (2).pptx")
@kelly_gilbert
I also tested without modifying the slide1.xml file and re-zipped the DELETE folder and renamed .zip to .pptx.
Same error occurred.
That was a great idea to test rezipping the file without modifying it! That tells us the problem is with the zip and not the XML. Are you possibly zipping the outer folder?
Make sure that you're just zippng the _rels, ppt, etc. folders, and the [Content_Types].xml file, and not the folder that contains them.
Thank you very much! I was creating zip file using the DELETE folder instead of zippng the _rels, ppt, etc. folders, and the [Content_Types].xml file.
If you have any tips on your process, could you please tell me:
1. When there are multiple projects to update the PowerPoint using the template, do you manually create the unzipped folder?
2. Do you embed the python code into the python tool in the alteryx workflow to zip the files and rename it to .pptx?
I'm so glad you got it working!
Q1 - I use Python to unzip the file as well as re-zip it after edits. I just finished converting the full edit process to Python, so my current workflow is:
However, if you want to use standard Alteryx tools for the text replacement, you could either use two Python tools (Python tool to unzip file --> replace text in Alteryx --> Python tool to re-zip file).
You can also use the Run Command tool with 7Zip to un-zip and re-zip the files.
One more idea: if you only have to edit specific slides, you don't have to unzip the file. You can import the slide XML directly using an Alteryx Input Data tool (select the .pptx file, then choose .zip as the file format, then click on File in Archive to select your slide XML file).
Then, once you've made your replacements, write out the new XML file to a temp directory.
Then, use Run Command to update the .zip file by adding the newly changed files (update command from the 7zip manual: http://7zip.bugaco.com/7zip/MANUAL/cmdline/commands/update.htm)
Note that this will modify the original zip file, so you will want to keep an extra copy of your blank template! Or, use a .bat file to copy the template .pptx first, and then update the copy.