How to read data table as an array

I want to read this Data Table as an array. I have tried for each row to convert it to an array but it still does not work. Below I have attached the data table. I would like to convert column “Holiday” to an array.
image

2 Likes

Hi,

Probably it will be the following.

arrObj = dt_datatble.AsEnumerable.Select(function(r) r("Holidays")).ToArray

or

arrStr = dt_datatble.AsEnumerable.Select(function(r) r("Holidays").ToString).ToArray

Regards,

2 Likes

Thanks for your help, but when I try to display the variable with a message box, it returns as “System.String” and not the date format @Yoichi

@kieranwong You can’t display whole array value in message box but you can display single array value by using its index example arrvariable(0).ToString

@indra

image

this is because you are using an writeline to write an array, use a for each, take a look :slight_smile:

table_Toarray.xaml (6.8 KB)
image


Don’t forget to like our post, and mark this post as solve if this answer your question.

Happy Automation :slight_smile:

4 Likes

@kieranwong

If you want to print that array values then use For Each loop and pass that array into it and inside that use Message box activity. It will print one by one value.

1 Like

@beesheep I can like your post but I can’t mark post as solved because i am not post creator :grinning:

1 Like

@lakshman and @indra haha I just got confused…hahaha

@kieranwong let us know if this solve your question.

2 Likes

@beesheep Thanks! It works
@indra @lakshman Thanks for your help too!

2 Likes

Your Welcome! :slight_smile:


Don’t forget to like us :heartpulse:
Happy Automation!

1 Like

Actually sorry to bother you guys again but how do i print out the my whole column like an array? @beesheep @indra @lakshman

@kieranwong :slight_smile: no worries man! (Asuming gender here–haha) It’s a pleasure to help.

string.join(";",arrStr)

image

image


Don’t forget to like us :heartpulse:
Happy Automation!

1 Like

May i ask if the array string can be converted to date time format? Right now it is in string format but i need it in Datetime format, I tired convert.ToDateTime however it gives me an error and I also tried to change the variable type.
Really sorry to bother you again. @beesheep

Dude, I am sorry I forgot that, my mistake, I’ll get back to you ok?

Regards,


Happy Automation! :sunglasses:

1 Like

sure

1 Like

Hello,

table_Toarray.xaml (7.2 KB)

Regards

Sorry but I would like to extract the dates in excel into a Datetime Array not into String Array.

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