Write automatically on the following excel sheet

good afternoon
There is a way in which it can be automatically described in the following excel sheet.
I mean write on sheet1, then sheet2, then sheet3
Use the “assign” activity with the value of “next + 1”, but I get an error
Eye: I am using it in a “write range” activity
if you can help me, thank you very much

Can you give a screenshot of your code or a more specific example? Perhaps a screenshot of the code? Is this within a for each loop? What do you mean by “next + 1” ?

I don’t believe you can reference a sheet by index in uipath, although this is possible in VBA. What you could do, is utilize the ‘Get Sheets’ activity, then use a for each loop and pass each sheet name in from the for each loop.

Excel scope:
Get sheets actvitiy // save as variable called sheets
For each sheet (of type string) in sheets:
Write range // the sheetname would be sheet
Next sheet
1 Like


I assume that your “next” is a integer data type.

So you need to pass as the following in the sheetname parameter

"Sheet" + Convert.ToString(next+1)
1 Like


thank you very much the last term you passed me I get error the one that says next
if it’s not very annoying you could see my workflow
read a folder of text files that I put them only as an example
I want your information to be written on an individual sheet of each text file as I told you
I mean you write the text file on sheet1, then on text2 the text file 2LeerArchivos_deCarpeta-20191120T174429Z-001.zip (28.0 KB)

Right now you are adding all of the text files to a single datatable called ‘Tabla’. Then you are passing that single datatable to a single sheet in your write range activity.

So you want each text file to be it’s own datatable, then each datatable to be it’s own sheet in a single excel file, correct? If so, I can mock up a quick example and attach

1 Like

That’s right, for each text file, I want it to be recorded on the same excel, but on different sheets,
if you could help me thank you very much

I get an error to complete the expression

@borismh - here you go. I commented out your flowchart and included my answer in the sequence at the top. I annotated throughout to hopefully help, but let me know if you have any questions.

Main.xaml (24.0 KB)

1 Like

thank you very much is a solution, in the “for each” you commented that it is for “.txt” true.
good to change it to “.xml” but I do not read anything if it is supposed to convert them to string files should be able to record them, there would be some solution for it
Thank you very much in advance

I am not 100% sure I follow, but if you want to read .xml files and skip any other file types (including.txt files), then change the Directory.GetFiles() so it searches for *.xml instead of *.txt

Note that .xml can be read still using the Read Text activity. However, if you want to parse it as XML to utilize XDocument, then you’ll have to read text, then use the ‘Deserialize XML’ activity

1 Like

thank you very much i managed to fix it
I am doing a workflow that reads xml files
If I have any other problems I hope you can help me

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.