Saturday, 15 February 2014

Export Datatable to Excel vb.net -



Export Datatable to Excel vb.net -

i trying export datatable excel in 2013 visual studio express web. while generating excel file, application throwing next error (see image attached)

-- code export

private function convertdttotdf(byval dt datatable, byval filename string) string dim dr datarow, ary() object, integer dim icol integer httpcontext.current.response.clear() httpcontext.current.response.addheader("content-disposition", "attachment;filename=" & filename & ".xls") httpcontext.current.response.charset = "" httpcontext.current.response.contenttype = "application/vnd.xls" 'output column headers icol = 0 dt.columns.count - 1 response.write(dt.columns(icol).tostring & vbtab) next response.write(vbcrlf) 'output info each dr in dt.rows ary = dr.itemarray = 0 ubound(ary) response.write(ary(i).tostring & vbtab) next response.write(vbcrlf) next httpcontext.current.response.end() end function

vb.net excel visual-studio-2013 export

No comments:

Post a Comment