Re order data table and writting Excel (simple questions)


#1

Hi
I have two questions:

  1. ) I have a data table like this one:

Name 1 | Type A
Name 2 | Type B
Name 3 | Type A
Name 4 | Type A

and i would like to re order it so that it looks like:

Name 1 | Type A
Name 3 | Type A
Name 4 | Type A
Name 2 | Type B

  1. ) I would like to write in Excel that data table but not in A1:B4 but: A1:B2 and A5:B6 (i mean in different ranges)

Thanks


#2

Hi @uipath_spain,

DataView view = date.DefaultView;
view.Sort = “date1 ASC”;
DataTable sortedDate = view.ToTable();

i did’t get you, can you provide sample input and output for this.

Regards,
Arivu


#3

Thanks a lot!!

What I mean is that I don’t want to write such a data table in one range in excel (A1:B4). I want to write the data table in two different ranges of Excel (for instance A1:B2 on one hand[in my example it should be written here

Name 1 | Type A

Name 2 | Type B

and A5:B6:

Name 3 | Type A

Name 4 | Type A

Thanks!!!


#4

Hi @uipath_spain,

Then use two write range to write in different position of the sheet.
1.
DataView view = date.DefaultView;
view.Sort = “date1 ASC”;
DataTable sortedDate = view.ToTable();
DataTable1.AsEnumerable().Take(2).CopyToDataTable()

DataView view = date.DefaultView;
view.Sort = “date1 Desc”;
DataTable sortedDate = view.ToTable();
DataTable1.AsEnumerable().Take(2).CopyToDataTable()

And in white range give the starting position.

Regards,
Arivu


Sort DataTable based on column value
Find Max value from datatable