Hello,

I am collecting reports via email then need to take out two columns (a fixed range) and add them to the log.

How can this be done

Hello,

I am collecting reports via email then need to take out two columns (a fixed range) and add them to the log.

How can this be done

1 Like

Are you getting columns of data as data table in HTML format of the email body or in the attachments @sparkplug93?

In excel attachments, then using read range to get the fixed range

If you want to read particular columns, you can use read column as well and then iterating them will give you the values of those.

To add them in the logs, How you want to add them?

At the end of whatâ€™s already there

Report 1 will be columns a and b

Report 2 will be columns c and d

etc etc

At the end of whatâ€™s already there

Report 1 will be columns a and b

Report 2 will be columns c and d

etc etc

So you can use the main datatable and filter it out with two columns into a new data table and another filter to make the remaining into another datatable right? If you know the column headings you can use them directly or you can use the index as well

So read the range of the two columns then make a data table?

Iâ€™m able to use read range and write the range to a specific spot but Iâ€™m having trouble making it dynamic. Where two columns come in and then next time two more go to the right of it

Read the second excel sheet and using its column count you can change dynamically the write range value.

Convert the numbers into excel column using this snippet

What do you mean by convert the numbers into an excel column

Fine

lets take like we have a excel report with columns A,B,C,D which is been read with READ RANGE ACTIVITY and a datatable variable named dt is obtained

now if we need to A and B as a first set of columns and C and D as second set of columns

then this expression would help you on that

**dt1 = dt.DefaultView.ToTable(False,â€ścolumnname1â€ť,â€ścolumnname2â€ť).CopyToDatatable()**

and

**dt2 = dt.DefaultView.ToTable(False,â€ścolumnname3â€ť,â€ścolumnname4â€ť).CopyToDatatable()**

where both dt1 and dt2 are variables of type System.Data.Datatable and is with default value as **New System.Data.Datatable**

Cheers @sparkplug93

To know the last written column or range from the target excel you need to get the column count

- Read Target Excel â†’ Output dtbTargetExcel
- dtbTargetExcel.Columns.Count - This is the range column count you will get
- Conver this count into excel column name

EX: If you get dtbTargetExcel.Columns.Count as 15

Then you need to write the additional two columns into range â€śP1â€ť

So to get the P1 - you need to Convert the 15+1 to the excel column name P - for that use that xaml which I have shared in my previous reply.

Using assign targetexcel=targetexcel.columns.count is giving me an error that it canâ€™t be converted to string

Iâ€™m confused at step 2 to the end

Count is an Integer, so you need to use Convert.ToString(targetexcel.columns.count) to convert that into a string. Else declare/change variable into an Integer type then try.

I need to use assign, correct?

Yes, you are correct