asp.net - Method to import excel to sql thru aspnet without using OleDB -
asp.net - Method to import excel to sql thru aspnet without using OleDB -
hi there ui/controllers aspnet(either c# or vb) or method read/dump excel sql without using openrowset(''microsoft.jet.oledb.4.0')? suggestion highly appreciated...thanks...
not sure if help but. utilize connection string vb.net form application.
sconnectionstring = "provider=microsoft.ace.oledb.12.0;data source=" & sfilename & ";extended properties = ""excel 12.0 xml;hdr=no""" ssql = "select * [sheet1$] f1 not null , f1 <> ''" dim oleconn new oledbconnection(sconnectionstring) dim cmd = new oledbcommand(ssql, oleconn) dim oleadapter new oledbdataadapter(cmd) oleadapter.fill(dt)
then utilize sql mass re-create write dt sql table
bulkcopy.columnmappings.add(0, 0) bulkcopy.destinationtablename = "sometable" bulkcopy.writetoserver(dt)
if don't utilize oledb, assume need utilize excel application object , create function iterate each columns , row data. http://vb.net-informations.com/excel-2007/vb.net_excel_2007_open_file.htm
dim xlapp excel.application dim xlworkbook excel.workbook dim xlworksheet excel.worksheet xlapp = new excel.applicationclass xlworkbook = xlapp.workbooks.open("c:\test1.xlsx") xlworksheet = xlworkbook.worksheets("sheet1") 'display cells value b2 msgbox(xlworksheet.cells(2, 2).value) 'edit cell new value xlworksheet.cells(2, 2) = "http://vb.net-informations.com" xlworkbook.close() xlapp.quit()
sql asp.net vb.net import-from-excel
Comments
Post a Comment