Read all file excel in folder and write range

Hi guys

i have read all file excel in a folder and then i want to write output values from get text to excel files that i have reads.
add new row with the header and write the values vertical in the same row while looping

Hi @gilang_ramadhan123

You can try with For each file in folder activity to get all the excel files inside the folder

Check out this Official documentation

Regards
Gokul

image

but how to write ouput ?
in the same file

hI @gilang_ramadhan123

Try like this

Instead of Merge datatable use another if activity

Regards
Sudharsan

Use Write Range Or Append Range activity to write the data in the same excel file @gilang_ramadhan123

Regards
Gokul

In that datatable field you need to give the datable variable that is used in the read range you used

image

If you created the that variable name as dt then you should use same dt in the write range or append range to

Writerange with add headers property will write the data in the excel file with headers

Append Range will write the data from the next cell where the datatable is already filled

Regards
Sudharsan

that is if only one file excel ?

how if more than 1 file excel

"C:\xampp\htdocs\MSCBooking\admin\upload\waylunik" + FileName

@gilang_ramadhan123

You are using this if inside a for each right?

So you can give file.ToString there it will get you all the files as per the loop

Regards
Sudharsan

Do you have any specific reason to use parallel for each? @gilang_ramadhan123

You can use normal for each because you are going to populate data in the same excel file

If you use parallel then your process might be ended up with error output file used by another process something like that @gilang_ramadhan123

Regards
Sudharsan

i use parallel for each because, i want to read all file excel

so i cant use parallel and write the output in the same excel as well ?

okey i use merger datatable, can i add some data to the merger datatable ?
and then every loop it will save in that merger datatable, after loop is done.
i write again all the merger datatable to new file excel

You can achieve it through normal for each too

Checkout this to know the differenc of both activities

Yes @gilang_ramadhan123

It will surely throw an error used by another process

Regards
Sudharsan

so i should make the process like this ?

excel application scope → read file excel → looping data to process → and then inside the application scope and the for each, i use write range ?

how to read excel file ignore the file name ? because file name will be different every upload @Sudharsan_Ka

and then what if in the folder there is more then 1 file excel ?

@gilang_ramadhan123

You dont need to change anything in your existing process

Just you need to replace that parallel for each into normal for each

Grab the for each activity

Copy all the activities in the parallel for each and paste inside the normal for each

and use item.ToString or Currentitem.ToString this will get you the filepath of each and every file while looping

Regards
Sudharsan

image
for each normal ?

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