Pasting the count and total count in excel

Hello!

How can i paste the count of each folders files in excel under the column?
I got the count of each files from the folder’s and also i got the total count of the files.
Know i want to paste that each files count and total count in excel under column name…Column name should be the folder’s name under that name there should be count pasted and at last there should be total count column under that there should be total count of the files.
Note that there is no excel sheet available to read.

Hi @Priyesh_Shetty1

1.Build a data table with column names.
2.Add data row activity to add the count

image

@lrtetala But the daily folder which contains files are not fix…sometimes there are 2 folder’s sometimes 3 folders like this it is
Folders name are-CAMS,KARVY,NDML,BSE,DOTEX,CVLKRA
these names are fix but daily there only 3 folders available sometimes 2,6 like this

@lrtetala So is there any way that it will dynamically take the available folder’s name and paste it in excel as column and it will paste the count and total count under column

Hi @Priyesh_Shetty1 ,

Step1: Create a datatable variable (DT)
Step2: Use assign activity

folderList = Directory.GetDirectories(“Your Folder Here”)
folderList variable type is Array of string

Step 3: Use for each for folderList
Inside for each use add data column activity

fileCount = Directory.GetFiles(currentItem.ToString).Count.ToString

values = if(values is nothing,fileCount,values+“,”+fileCount)

Step 4= Use Add data row activity

Step5 = Use write range activity to write DT

FilesCount.xaml (10.7 KB)

Thanks!

@Umadevi_Sanjeevi error in add data column-Object reference not set to an instance of an object…This is the error in add data column.

Hi @Priyesh_Shetty1 ,

Initialize DT variable like below.

New System.Data.Datatable()

Thanks!

@Umadevi_Sanjeevi Iam getting the count but that each file count should be pasted under the column…And that column name should be the Folder’s name from which file has been counted.

Hi @Priyesh_Shetty1 ,

You can get your expected result with same code.

For example:

Folder1
file1.xlsx
file2.xlsx
Folder2
file1.xlsx
Folder3
file1.xlsx
file2.xlsx
file3.xlsx

Your output will be

Folder1 Folder2 Folder3
2 1 3

FilesCount.xaml (11.0 KB)

Thanks

@Umadevi_Sanjeevi it is pasting only count in the excel after using the same logic.

Hi @Priyesh_Shetty1 ,

If your using write range activity to write the DT. Check “AddHeaders” property in property panel.

Thanks!

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