private sub btn作成_Click(sender as object,e as eventargs)handles btn作成.click If txtpath.text =“” then exit sub end if
btn作成.enabled =false
dim str as string =“” dim strcount =0
dim ex as new Microsoft.office.interop.Excel.application dim sh as Microsoft.office.interop.Excel.worksheet dim wb as Microsoft.office.interop.Excel.workbook dim range as Microsoft.office.interop.Excel.range
For rw as integer =0 to dgv.rowcount -1 if dgv.rows(rw).cells(“選択”).value=1 then str=dgv.row(rw).cells(“品名”).value & vbcrlf str &= dgv.row(rw).cells(“数量”).value & vbcrlf str &= dgv.row(rw).cells(“単位”).value & vbcrlf
if strcount =0 then wb=ex.workbooks.open (txtpath.text) sh=ex.worksheets(“発注”)
dim strarry() as string =str.split({environment.newline},stringsplitoptions.none) dim arrycount =0
for col as integer =1 to range.columns.count range.cells(1,col).value =strarry(arrycount) system.runtime.InteropService.Marshal.release comobject(range.cells(1,col)) arrycount =arrycount + 1 next