How to delete Empty Collection Columns

Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-09-19 12:29 PM
Hi guys,
Just a quick one. I have a collection with many empty columns at the end and i would like to delete them all.
Is there a possibility to do that? They are somehow dynamical displayed, sometimes there are data, and sometimes they don't have.
How can I do that?
Thank you,
Ionut Cohen
------------------------------
Ionut Cohen
RPA Developer
Luxoft Romania
Europe\Bucharest
------------------------------
Just a quick one. I have a collection with many empty columns at the end and i would like to delete them all.
Is there a possibility to do that? They are somehow dynamical displayed, sometimes there are data, and sometimes they don't have.
How can I do that?
Thank you,
Ionut Cohen
------------------------------
Ionut Cohen
RPA Developer
Luxoft Romania
Europe\Bucharest
------------------------------
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-09-19 03:26 PM
Here's a C# stage I wrote.
Edit: I apologize ahead of time for the inefficiency of this one, especially if there's a ton of columns. I'm keen to see if anyone has a better solution!
Inputs:
Collection - Collection
Outputs:
New Collection - Collection
DataView dv = Collection.DefaultView; //Label to prevent 'Collection was modified' errors Out: foreach(DataColumn col in Collection.Columns) { if(col.DataType == System.Type.GetType("System.String")) dv.RowFilter = col.Caption+" =''"; else dv.RowFilter = col.Caption.ToString() + " = null"; if(dv.Count == Collection.Rows.Count) { Collection.Columns.Remove(col); goto Out; } } New_Collection = Collection;
------------------------------
Ami Barrett
Lead RPA Software Developer
Solai & Cameron
America/Chicago
------------------------------
