i want to extract only this two row and save it another sheet.
and second scenario is below
like i want to extract mid row value and save another sheet.
Middle 2 Rows
middleTwoRows = dt_Input.AsEnumerable().Skip((dt_Input.Rows.Count - 2) \ 2).Take(2).CopyToDataTable()
First 2 rows
firstTwoRows = dt_Input.AsEnumerable().Take(2).CopyToDataTable()
can you explain please
.Skip((dt_Input.Rows.Count - 2) \ 2)
: Skips a certain number of rows. In this case, it calculates the index to skip based on the formula (dt_Input.Rows.Count - 2) \ 2
. The backslash \
represents integer division in VB.NET. This part is used to skip rows before the calculated index.
.Take(2)
: Takes the next two rows after skipping. This ensures that you are selecting the middle two rows.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.