Excel write range


#1

Hi,

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


#2

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

Regards
Balamurugan


#3

@balupad14

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


#4

Hi @vikumars,

Below I have attached the Project.

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

Regards
Balamurugan


#5

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


#6

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


#7

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


#8

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: