vb.net - Take Data Grid View Data And put it into Excel -
vb.net - Take Data Grid View Data And put it into Excel -
hello here trying do. have tab command 10 tabs each tab has own datagridview , same 6 columns , rows hold data. rows vary each tab. need take info in rows , place them in excel. have 10 datagridviews called dgvs, dgvhrdf, dgvhrdf, dgvr, dgvrt, dgvp need place info in cells each info table. if there no info in table skip , goto next table.
dim integer dim j integer 'open blank excel file. oxl = ctype(createobject("excel.application"), excel.application) 'sets oxl visible off can't see open. oxl.visible = false ' open sheet blank sheet. owb = oxl.workbooks.open("c:\template.xlsm") 'set osheet active sheet. osheet = ctype(owb.activesheet, excel.worksheet) 'here set excel sheet. on error resume next = 0 dgvs.rowcount - 1 j = 0 dgvs.columncount - 1 k integer = 1 dgvs.columns.count osheet.cells(54, k) = dgvs.columns(k + 1).headertext osheet.cells(i + 53, j + 1) = dgvs(j, i).value.tostring() next next next end sub
vb.net
Comments
Post a Comment