How to find header data in excel

The header data could be in any row number be it 20 r 21 and the data after needs to be considered for business process. So I need to find header and proceed further. Any suggestions would be helpful.

Thanks,
Nawaz.

Hi @Mohammed_Nawazuddin ,

The Read Range Activity is pretty smart - it will automatically understand where the header is regardless of the row it starts at when you leave the Range blank.

image

image

image

If its unable to detect the right row to start from, you could simply leave the range blank and use a SkipWhile iterator to skip the empty rows until it finds cells that contain data:

Dt.AsEnumerable().SkipWhile(Function(sk) IsNothing(sk(0)) OrElse String.IsNullOrEmpty(sk(0).ToString)).CopyToDataTable()

Sample data would be most appreciated so that I can work out a solution for you.

Kind Regards,
Ashwin A.K

Thanks for quick response.

Please find the below snapshot as the 21 line is header and before that data needs to be skip
ed

Thanks,
Nawaz

Hello @Mohammed_Nawazuddin

Please share the sample excel file here.

Thanks

Hi,

Please find the attached excel file

line 10 is header.

sample.xlsx (8.1 KB)

Thanks,
Nawaz.

@Mohammed_Nawazuddin

  1. Read whole data into datatable dt…
  2. Now use lookup table to find Date…which gives you the row number…
  3. Now use skip …dt.AsEnumerable.Skip(number).Copytodatatable

If you want to assign first row now as header then

  • Loop the first row using For Each activity
  • Then Assign dt.Columns(columnIndex).ColumnName = firstRow(columnIndex) this will rename the header
  • After the loop delete the first row

Cheers