Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

How to rename a template in excel after copying and inserting the data

Nithinpanicker
8 - Asteroid

I have a template in excel file. I have designed a workflow to copy the template file from a folder to output folder in order to preserve the template using a batch command and then inserted all the data that I require into the template. But I would like the template to be renamed after the data has been inserted with the date the workflow has been run. For example: Output_yyyy-mm-dd.

 

Any help will be appreciated.

16 REPLIES 16
DataNath
17 - Castor

@Nithinpanicker if you select to 'Preserve formatting on Overwrite' in the Output Data tool configuration, then select the range (this will just be all the cells your template covers), does this remedy the issue?

 

DataNath_0-1655197646314.png

 

Nithinpanicker
8 - Asteroid

@DataNath 

 

Unfortunately that did not work. Now while running the workflow, I have 2 outputs. The template which is copied from the template to output folder and the data set which is renamed with the data but not inserted into the template.

DataNath
17 - Castor

If you change the 'Output Options' to 'Overwrite Sheet (Drop)' does that solve the issue? Still keeping all other config the same. Apologies, I'm no longer at my laptop with an Alteryx install so can't play around myself, though I'm fairly sure it's just an issue in the Output configuration.

DavidP
17 - Castor
17 - Castor

Hi @Nithinpanicker 

 

I think what you should do is when you copy the template with the Run Command tool, insert the date stamp in the DOS command so that the new file is created with the date stamp already in the filename. Then when you're writing data to the new file, you just have to make sure that the correct filename is used.

 

This post shows an example of how to do this.

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Editing-and-saving-a-macro-enabled-fil...

 

Nithinpanicker
8 - Asteroid

@DataNath 

 

No worries. No it still does not seem to be working. Its still not merging the data onto the template. The file renaming appears to be working but its not entering on to the template. Do you think maybe I can setup an event to run a batch file to rename the file after running the workflow?

DataNath
17 - Castor

@Nithinpanicker I've just been looking at the screenshot of your current flow again and had a thought.

 

For the bottom (3rd) stream, could you not just:

- Dynamically input this most recently copied template file (where the data has been populated)

- Create the custom file path (with date appended to name) as outlined in previous posts

- Instantly output the file again, configuring the output to overwrite this file

 

In theory, this should just bring in the file from your middle stream (which you mention is working fine) and then instantly output it again, applying the rename from your custom formula.

grazitti_sapna
17 - Castor

@Nithinpanicker, this can be achieved using a blob tool as well instead of a batch command, if you have an existing template then you can create a new file output_2022-06-15 and then store the data in that file where the date would be dynamic by using DateTimeNow().

 

In the template copier tool container, I used the path of the template file to be copied and stored in a blob then using the formula tool made changes to the file name and then output the template using blob output.

grazitti_sapna_0-1655272036607.png

 

 

This is my template

grazitti_sapna_1-1655271831222.png

 

Output Template

 

grazitti_sapna_2-1655271860415.png

 

 

This actually worked for me, if it will be possible for you to share a replica of your workflow containing dummy data I can try to implement the same.

 

I hope this helps!

 

Thanks!

Sapna Gupta
Labels