Excel write range


How to write value stored in the variable into excel sheet using write range activity.

eg: If i assign a value to a DataTable variable, following errors throws
value of type ‘string’ cannot be converted to System.Data.Datatable

Hi @vikumars,
You can not assign the string value “CHANGEME2” .can able to assign only the datatable or New instance. like “New System.Data.DataTable”.



Could you please provide me sample, so that it could be easy to understand

Hi @vikumars,

Below I have attached the Project.

File : Adding Columns to a datatable.zip (14.9 KB)


I too get a similar error while writing a datatable extract to csv

  • System.Activities.Invalid WorkflowException: The workflow has validation errors. Review and resolve them first. —> System.Activities.ValidationException: Compiler error(s) encountered processing expression “ExtractDataTable”. Value of type ‘System.Data.DataTable’ cannot be converted to 'String

Hey @Crimsonarcher
The write text file activity only takes a string type value as input, hence you’ll have to convert your ExtractDataTable variable into a string type value.

To do that before ‘write text file’ activity put a ‘output data table’ activity,
In the input property give ExtractDataTable
In the output property create a string variable
And then give that string variable as input to the ‘write text file’ activity.

NOTE- If you want to create a csv file use the write csv activity and not write text file. in write csv activity you can pass the ExtractDataTable directly as it takes a DataTable as input

Perfect… this worked!
But the formatting is off, because the source page doesn’t follow a standard pattern. I’ll have to see how to fix the extraction from browser

Yes you’ll have to do that! :slight_smile:
if its a .csv file just use write csv activity and give ExtractDataTable as input, everythng will be structured :slight_smile:

I want to write a data table into a excel but when I checked Add headers it starts writing the content from 3rd row and the second row goes blank. I don’t want to keep this 2nd row blank. Is there any way to do this??