Help with Null Ref error when reading Excel col to String Array

I have to cols in a excel file that I want to read and, for each col, I want to write the entries to an arrat var. So these two now becomes:
image
image

image

arrayOfNamesCol = {"engr1", "engr2".........}
arrayOfRoleCol = {"lead","Assoc"............}

I have tried two approaches:
1 .


but I’m getting a null Ref exception.
Attached is my attempt, I’d appreciate help figuring out what I’m doing wrong
readExcelColEntriesToArray.zip (9.6 KB)

@Yomi_Oluwadara

i have tested the workflow which you have shared i didnt see any exception

arrayOfNamesCol=dt_excelContent.AsEnumerable.Select(Function(a) a("Name").ToString).ToArray

image

or if you want to use for each row in data table activity

just refer the xaml

readExcelColEntriesToArray.zip (10.3 KB)

Thanks, following your logic for the first col. I tried to read and convert the second col, but I got a null ref. Do you know why this might be the case ?

I know the DT has the second col because I outpye the DT :slight_smile:
image

image

I have re-attached my workflow (main.xaml) kindly help take a look
readExcelColEntriesToArray.zip (12.1 KB)

Hi @Yomi_Oluwadara

arrayOfNames As String[] = dt.AsEnumerable().Select(Function(row) row.Field(Of String)("Name")).ToArray()
 arrayOfRole As String[] = dt.AsEnumerable().Select(Function(row) row.Field(Of String)("Role")).ToArray()

Output

Hope it helps!!

@pravallikapaluri
Thanks for your reply. I tied that approach as well (main2.xaml) in the attached. However, it seems I have an empty string
image

While I try to figure this out, if the reason for this jumps out at you, kindly let me know.
readExcelColEntriesToArray.zip (12.1 KB)

@Yomi_Oluwadara

readExcelColEntriesToArray (1).zip (13.2 KB)

1 Like

@Shiva_Nikhil and @pravallikapaluri Thanks to you both.,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.