import excel skip the fist 3 lines

  • Thread starter Thread starter tim_pear
  • Start date Start date
T

tim_pear

Guest
Hi all

im using closed xml to import an excel file into a datagridview ive almost got it working but I need to tweak the code I need to skip past the first 4 rows of data in the excel sheet before processing the header and then the data the code ive got so far works if I delete the first 4 rows before importing this was fine for testing but need tweaking for production my code so far is

dim firstrow as boolean = true
for each cell as ixlcill in row.cells

if first row then
dt.columns.add(cell.value.tostring())
next first row = false

else

dt.rows.add
dim I as integer = 0
for each cell as ixlcell in row.cells
dt.rows(dt.rows.count - 1)(i) = cell.value.tostring()
if I = 28 then
exit for
end if
I += 1
next
end if

Continue reading...
 
Back
Top