About Read Column Errors

excel
activities

#1

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?


#2

Hi,
True.
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:
@ovi


Issue in Read Column Activity
#3

Explain more?


#4

Sending meeting invitation .:joy:


#5

:face_with_raised_eyebrow::face_with_raised_eyebrow::face_with_raised_eyebrow::face_with_raised_eyebrow:
Not free Now
:face_with_head_bandage::face_with_thermometer::face_with_thermometer:


#6

@ddpadil
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.
Mmm…


#7

Yes.
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.


#8

I tried a workflow as below.


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


#9

Yes.
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:
@andrzej.kniola


#10

Oh I understand. So I should set C1.

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


img4

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:


#11

Hi,
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.

Else

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


#12

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


#13

Hi,
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


#14

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.

Regards…!!
AKsh