How to delete columns in a collection

junjie

Member
VJ
i have an idea, shall we work on the excel to remove " .000" of that column?
if possible, which action to do and how to write in its property?
 

junjie

Member
we do this stage after the get worksheet as collection? (at this stage we have collection 1, and the column Rate has decimals)
next, we add the stage Calculation to roundup the column Rate
but at the store in, it's a text, not a collection.
how to get this roundup reflected inside the collection 1, or ... ?
i need to have the collection 1 with column Rate no more decimal, after that, i will do the Yes/No checking.
 

junjie

Member
Hi :)
by the way, how to make the value turns into 3 digits?
for example, now, the cells value is 5
how we can make it show "005" ?
in a column, all the rows value needs to be shown in a 3 digits ( for example: a12, b11, and if there's a value 15, make it show 015 )
 

junjie

Member
i try the Rndup
but it seems only apply for a specific number?
however, i want to do for the entire column Rate.
i try RndUp([Rate],0) but it says error : missing data [Rate] :(
 

junjie

Member
it seems this RndDn stage is to be done after we have the collection
then will indicate the collection.column in RnDn
but the store in is just a number data
need this column to reflect back to the excel file , and so , have a new collection and this column is now no more decimal
how i can resolve this :( :(
 

VJR

Well-Known Member
Hi junjie,

There are 5 recent posts and it is not clear what the exact issue is. Please post screenshots with complete details of what the issue is.
 

anjali

New Member
Your input and output collection name should be same . Attaching a reference i recently used in one of my project .
Here in DeleteColumncollection i have only one column "Values" which has name of all the columns that i want to delete . When you loop in , it will take column name and delete it .
 

Attachments

  • DeleteColumn Collection.PNG
    5.8 KB · Views: 35
  • Loop Collection.PNG
    23.5 KB · Views: 29

Aparna

Member
oh oh ...thanks :)
i make corrections.
now, it runs alright.
but i notice it only deleted the columns has value 0. ? (and this column is the one i put at the last row in the initial value)
the other columns still remain ... :(

shall i need to add any value in ?
Hi Junjie,

Did you resolve this problem, I do have same issue, I want to delete empty columns in collections. If you know the solution please let me know...

Thanks in advance...
Aparna.
 

RPA_1

Member
How do I delete and empty column. Catch is that I don't know the column or columns which might be empty in collection. Is there a way to do it without knowing the column name ??
 

Aparna

Member
Hi RPA_1
Use this C# code in code stage, it will delete empty columns in collections with out knowing column name.
Input: Collection In
Output: Collection Out

Code:

DataTable table = Collection_In;
List<DataColumn> listToDelete = new List<DataColumn>();
bool deleteColumn = false;
foreach (DataColumn c in table.Columns){
foreach (DataRow r in table.Rows){
if (String.IsNullOrWhiteSpace(r[c.ColumnName].ToString())){
deleteColumn = true;
}
else
{
deleteColumn = false;
break;
}
}
if (deleteColumn) {
listToDelete.Add(c);
}
}
foreach (DataColumn c in listToDelete){
table.Columns.Remove(table.Columns[c.ColumnName]);
}
Collection_Out = table;
 
Top