Hi,
I need a kind help to remove the first two rows of an Excel file.
Here I attach the Excel file that I’m analyzing. Lista_targhe.xlsx (7.9 KB)
I tried to remove the first 2 rows of the DataTable generating by the Read Range, but it deletes the first and the third.
This is what I would use except you don’t need the .Take() unless you only want to take a certain number of rows. In your case, you want the remaining table, so you can leave it off, like this:
Thank you so much @ClaytonM.
It works only without the part of code Take(DTVar.Rows.Count-2) because I only need to take the table without the first two rows and overwrite it to old one.
Thank you for your kind help.
Camilla
I will also mention another tip on this where you can use the Index of a row as the number of rows to skip. This will be useful if there is a chance that “2” could change in the future or if you are manipulating spreadsheets on multiple customers where there could be differences.
Basically, here I am using .Where to find the row that has a key word or header name, then placing that row in .Rows.IndexOf() to find the index of where that row starts at. I can then use that number in the .Skip(), instead of hardcoding the number 2.