Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Looking for a way to Input results into a premade word document.

JohnGagnon2000
5 - Atom

There is a standardized word document with many sections to fill. I would like to use this doc as a template as I cannot remake all the features within the reporting tools. Is there a way to output to specific areas in a word document and leave the rest alone? I see results pointing to the report and layout tools, but I cannot think of a way to make that work for me. Suggestions and examples would be great!

 

If I could import a template for the layout tool to recognize and copy that would be ok, but to remake the entire report would be not worth the effort and I am unsure how to use the formatting tool to precisely recreate the document in a way to not cause errors.

 

Items to edit:

Header

Footer

Swapping Characters/text

Filling named text boxes

6 REPLIES 6
OTrieger
11 - Bolide

@JohnGagnon2000 
Yes there is a way how to do it.

However first you will need to create a Word Doc template that Alteryx will always going to use to generate a new Word file.

 

So the answer is yes, it is possible.

Qiu
21 - Polaris
21 - Polaris

@JohnGagnon2000 
As far I know, we can do something similar to the Excel template as described here.
But I am aware that there is a way we can output some particular content to the specific location for Word file.

Maybe Python?

https://community.alteryx.com/t5/Engine-Works/The-Blob-Reporting-That-Isn-t-From-a-Horror-Film/ba-p/...

OTrieger
11 - Bolide

Hi @Qiu 

We actually can create design Word Doc with Alteryx, it requires some preparation steps however it is possible. I already created workflows that generating reports on Word doc and without the use of Render as it will not be the solution here.

@JohnGagnon2000 
Ok that will be a big long description, this is a solution that I managed to figure out at the beginning of this year and it will work only with docx format files. All the PPTX, DOCX, XLSX etc formats are actually an XML files. I guess now you start to think what is my solution :)

So it is super important to replace the text that you will want to replace to a very unique text so you can easily be able to replace it in Alteryx, For simple text as Name, Date etc you can use what you want I normally would do something as Bi19ll, 01/88/9999 depends on the date format. For paragraphs or sections in paragraphs I would just use dfds878gh etc. just long string without any spaces or comas, 10-20 characters. 
Now that you template is ready, save it in a separate folder just for this project.
Unzip the Word file and you will get several folders and files. Move all of them into a sub folder, why, because what Alteryx will do it will update these files and then you will need to zip them back into Word Doc file, so you want to have all the files in one separate folder, you will use Ran Command to zip these files.
Now go back to the original folder and create on sub folder for the XML template files, why are you want to have the original template unchanged, this will let you later own to recreate as many Word Doc as you wish. 

All my above instructions are based on my personal experience and where I lost time, so if you follow the above then you will be good.

In Word folder, one the folders that you exported the data. You will find all the XML files. You will have files for the headers footers etc. Copy all these XMLs files and paste them into the Template folder.

Template folder will be the input source for Alteryx. The Word folder will be your target output location.

So what you will need to do in Alteryx will be, connect the templates that you want to replace the data to Alteryx. I import it as csv file as I would like to have the full XML format in Alteryx, then I will use RecordID to ENSURE that I do not messing up the xml schema.

You will need now to input the new data, create mapping based on RecordID, replace the unique text that you have in the template with the new text.

Put all the XML together back to the original order, only with the new values. Remove the RecordID and save it to the target location with the original name such as, document.xml


After that you saved all the XML files, you then need to zip everything that in that subfolder, with Run Command and then with another Run Command you will need to rename the file to whatever naming you want, but it must be xlsx format.

Good luck!

The above is working perfectly for me and we are generating formatted reports, contracts, etc.

JohnGagnon2000
5 - Atom

My XML seems to cut off upon import. How did you import the XML file as CSV. I located the relevant XML files for the body, header, footer, etc. and opening them with MS Edge allows me to see the information I set in the template to my unique values, but I cannot view it within Alteryx.

 

Could you share an example and/or screenshot of your setup? I have tried all options of root, child and others within the XML selection. I have tried importing it as a CSV. Nothing seems to work for how this XML is split up.

 

I appreciate your help already as it is a great start, but you seem way more advanced than me, so I got lost in the steps you brushed off as basic.

 

Thank you!

OTrieger
11 - Bolide

You are getting all the data however you need to parse it. I'm using a formula tool to insert a unique delimiter that later on will parse the text to rows based on it.

Replace([Field_1], "<", "~<")

Then will add a RecordID, a crucial step, as now you are parse the text and before saving it into xml you will need to concatenate it back to the original format, of the 2 lines. The RecordID will enable you to sort the data in the correct order.
yy.PNG

Qiu
21 - Polaris
21 - Polaris

@OTrieger 

Thats very good to know.

Let me study more about your approach. Thanks for sharing.

Labels