About Read Column Errors

Hi, there!

I’m trying to use Read Column activities from different excel files.
The outputs of Read Column which have more than two elements are working.
The outputs which have only one element do not work.
For example, message box (output.FIrst().ToString()) throw NullReferenceException.
(However, output.count().Tostring() says “1”)

Do you have solutions?
IEnumerable variables should have more than two elements?

1 Like

Try to replicate the scenario .
But when I tried to change read column Starting cell property to other 1(default is A1) eg: A2 or A3.… so on then its returning first value correctly.
strange isn’t it. :stuck_out_tongue:

1 Like

Explain more?

Sending meeting invitation .:joy:

Not free Now

Did you try when column has only one element? (eg: A1 only,A2 only…)
I aso tried to change read colmn starting cell property,
but I still have same problems.

I tried with one element only.
No matter which cell that single item falls in, its working if i mention “Starting cell property” other than A1.

I tried a workflow as below.

This is an excel file.
When I set starting cell property “B2”, it works.
When I set starting cell property “C2”, it throws NullReferenceException.:tired_face:

Because the index starts from 0 not 1.
So if you give B3 it start reading from cell 4 which is null in excel and hence it throw error .
So same for C2 .

PS: but where as if you give B4,5,6…so on it won’t hit any exception.
Don’t know whats happening here :stuck_out_tongue:

Oh I understand. So I should set C1.

But next step, I want to use For each loop like this.


I wanna use only C3 “test1”. So I dont need a cell C2 “Title”.
When I set starting cell property C2 , it returns extra C2.
When I set starting cell property C3, it throws Exception.

Yeah… It is strange. Even B100 won’t hit any exception.:thinking:

Looping ?:roll_eyes:
You required only for first item right?
If you wants to read each item of unique column then there is multiple way to do it.

  • Use read range activity which returns the Datatable use foreach row item activity and place get row item activity inside it and pass the column name/index to retrieve each item.


create var int cnt=1
assign cnt= cnt+1
Use read cell activity directly and pass the cell as (cell+cnt.tostring)

It works!!
I will use read range and for each row activities from now on.
Thanks a lot!

1 Like

This is my scenario. I need to read column A and i need to get the count of total number of element present it.But when i use read column activity it is showing error as

Kindly help me how to resolve this situation

Hey @nirsha

Sorry for the delay. just busy with work :slight_smile:

well if in general you want to know the column data values count then you can get it by below code.

Better to read all your excel into a Datatable then just pass the column name which data values count you wanna get.

Int32 col_Count = Your_Datatable_Name.AsEnumerable().Select(Function(r) r.Field(Of Int32)("Col1")).Count()

Note- Filed type depends on your column filed datatype and similarly replace your column name with Col1.