vb.net - DataGrid export to excel -
i have datagrid control
fills data se
t.
i don't show fields of data set in datagrid control.
i want create excel file
datagrid
.
how solution?
(windows form , vb net 1.1
)
try link
or
try this
imports excel = microsoft.office.interop.excel dim excel new microsoft.office.interop.excel.applicationclass dim wbook microsoft.office.interop.excel.workbook dim wsheet microsoft.office.interop.excel.worksheet wbook = excel.workbooks.add(system.reflection.missing.value) wsheet = wbook.sheets("sheet1") wbook .sheets("sheet1").select() .sheets(1).name = "nameyoursheet" end = 0 datagrid1.rowcount - 1 j = 0 datagrid1.columncount - 1 wsheet.cells(i + 1, j + 1).value = datagrid1.rows(i).cells(j).value.tosring next j next wsheet.columns.autofit()
Comments
Post a Comment