How to Remove empty columns in excel using uipath

Hello everyone , I’m working on a excel sheet I have some data in that excel . In that data some columns are empty. I want to remove those empty columns completely and I want to re write the data in same excel sheet can anyone help me how to solve this.

Input data

I need output should be like this

1 Like

@ranaprathap928 - Please check this post…i have provided to the similar problem…

Input
image

Query
dtInput.AsEnumerable().Where(Function(row) Not(row(“Retry”) Is DBNull.Value Or row(“Retry”).Equals(“”) )).CopyToDataTable

Output

image

If this helps, please mark my post as solution.

Thanks @prasath17 let me try this

@prasath17 I’m not getting “AsEnumerable” for that which package I need to install

Can you please share your query. Dtinput comes from your Read Range…

Please check what is your readrange output variable…

Also check this post on how to fix it(if the error persist).

Hello @ranaprathap928,

you can also try filter datatable activity as shown n below image.

image

@Akshay07 I tried filter data table but it’s not working properly I will check once again

@ranaprathap928 …Please find the starter help here…

DeleteEmptyRows.zip (47.1 KB)

@prasath17 after adding that into uipath xaml also I’m not getting “AsEnumerable”. My read range output I’m using in that code

@ranaprathap928 - Please share your query…and the error…

@Akshay07 while I’m filtering data I’m able to write that data in another excel sheet but I want write the updated data in same excel sheet by removing that empty columns

@prasath17 I’m not getting AsEnumerable

I added data extension in main Xaml also

Hello @ranaprathap928,

Thats simple !!!
In output Datatable use the same datatable variable as Input Datatable and use write range activity to write the excel with the same file name.

eg. Input Datatable = InDt and Output DataTable = InDt.

Mark this as solution if it solved you problem.

Sure @Akshay07 I will check this

Thanks for adding the missing item…Have you closed and reopened it again…Just making sure…(as shown in this video)

@prasath17 in your Xaml it’s working fine when I copy that code to my Xaml I’m getting error

I changed input variables also like in your xaml

Thanks @prasath17 it’s working

Thanks @Akshay07 even filter data table which you shared that also working , I can’t make both solutions I guess. Thanks for your help guys.

@ranaprathap928…glad you were able to solved…

Yes @Akshay07 solution is also works…only thing with the LINQ is , Faster…you have more # of rows in ur excel then this guy does the job much faster.

Yes @prasath17 @Akshay07 thanks for your help.