How to convert text string to datatable variable

Hi all,
I want to extract text from pdf to excel. I got text from pdf file to variable string.
Now, i want to convert text string to datatable variable type and write range in excell. How to do it?

1 Like

Hi @AKY,

  • First create data table using build data table activity

  • Split your string using environment.newline ,space,tab or any special char append it into datatable.

  • using write range activity to write the data into excel file.


Hi Arivu,

How to split the string using environment.newline?/

Hi @balu,

StrValue-string variable
Arrayvariable - array of String variable String

Split the string value using Newline using below code it will return output as array of String value.



1 Like

hello @arivu96,
I am trying to split data from an excel sheet which is separated by spaces on a single column. So I took the data convert it into string and tried to split it the way you have mentioned here but while doing so I get an error message which assigning the split function to the array as the Environment.Newline cannot be assigned to the array of 1 dimension. Can you assist me please.

Thank you,

@BinitaS Please check the workflow this is what arivu said
@AKY Please find the workflow Below
Main.xaml (15.0 KB)

1 Like

hi…im having the same issue i want to convert my variable to datatable but want to write range in my existing excel file…i cant use build data right for this case. Do you have any other solution ?


Hello @Sharmilah_Devi you can use write range and specify the range you want to write the data on

1 Like

the file is corrupt.
can u please explain how to convert scrapped data from web to data table?


If the extracted data (input string) has fixed separator for columns and rows, you can make use of Generate Datatable activity. You need to pass your string as input, specify column and row separators and it will give datatable as output.

1 Like

actually i want to extract email body data.
i have tried get text, get ocr text , cv get text activity also but unable to get the data.
any suggestion bro?

Thanks for reply

Get the E-mail Message and store it in List, then do a For Loop for System.Net.Mail.MailMessage and get the Body by Item.Body.ToString. If you reading an Text E-mail.

actually i want to get this text

what activity sud i use to scrape it
thanks for the reply

From where are you reading the E-mails? If it is from Outlook use Get Outlook Message and then Do the For loop as I mentioned before. That will give you the Body content of an e-mail.

not from outlook
from chrome
or sud i use get i map mail message activity

You can use any of the mail activities available in UiPath according to your requirement. Other Outlook activity rest all asks for Port, Server and other details which are mandatory get the mail message. Any how all those activities returns List store that variable and perform the For Loop. Thanks.

1 Like

Hey hi @vickydas, I also have same example needed. But getting error as,

Add Data Row: Object reference not set to an instance of an object.

Attached the xaml and pdf files. Can you please look into it and tell me what is the issue from my side.

8130-3_sample_for_demo.pdf (32.5 KB)
Main (4).xaml (17.9 KB)

Thanks in advance.

1 Like

hello @sushmithaelluru

This error occurs when the activity does’nt get value to perform its function so its throws this exception

Back to your problem You have assigned dt variable to build data table activity and in Add Data Row you have inputted DT1 Variable so the activity is not getting any table to add that particular row so make that change in your workflow and it’ll work fine

1 Like

Hey hi @vickydas, thanks much . But am getting the data which is not in ordered way in the CSV. Can you please look into it once,

opp.xlsx (11.1 KB)

1 Like

hello @sushmithaelluru

I did’nt get you Could you please explain me what you want in detail ?
You have attached a blank excel file what should it contain ? :slight_smile:

1 Like