asp教程.net 读取excel数据
imports microsoft.office.interop
partial class _excel
inherits system.web.ui.pageprotected sub btnrexcel_click(byval sender as object, byval e as system.eventargs) handles btnrexcel.click
dim strpath as string = file1.postedfile.filename
if strpath = "" then
me.response.write("请选择要导入的excel数据文件!")
elsedim excelfilepath as string = strpath
dim myexcel as excel.application = new excel.applicationclass() '创建一个excel对象
dim omissing as object = system.reflection.missing.value
myexcel.application.workbooks.open(excelfilepath, omissing, omissing, omissing, omissing, omissing, omissing, omissing, omissing, omissing, omissing, omissing, omissing, omissing, omissing)
dim mybook as excel.workbook = myexcel.workbooks(1) '定义一个工作表组
dim mysheet as excel.worksheet = ctype(mybook.worksheets(cint(textbox3.text)), excel.worksheet) '定义一个工作表dim r as excel.range = ctype(mysheet.cells(cint(textbox1.text), cint(textbox2.text)), excel.range)
me.response.write("excel中第" & textbox1.text & "行 第" & textbox2.text & "列的值:" & (r.value).tostring)
excelgc(myexcel, mybook, mysheet, r)end if
end sub
'关闭excel进程
private shared sub excelgc(byref myexcel as excel.application, byref mybook as excel.workbook, byref mysheet as excel.worksheet, byref r as excel.range)
mybook.close(false, type.missing, type.missing)
myexcel.quit()
system.runtime.interops教程ervices.marshal.releasecomobject(r)
system.runtime.interopservices.marshal.releasecomobject(myexcel)
system.runtime.interopservices.marshal.releasecomobject(mysheet)
system.runtime.interopservices.marshal.releasecomobject(mybook)
mysheet = nothing
mybook = nothing
myexcel = nothing
r = nothing
gc.collect()
end sub
end class
%>
洋果子店rose最新版本
洋果子店最新版是一款十分容易让人垂涎的开店经营类手游。游戏玩
明日大亨最新版
明日大亨手游,一个非常经典有趣的模拟经营类型的商战手游,在游
早安我的少年日服最新版2024
早安我的少年日服是一款治愈恋爱手游,清新明亮的游戏画面,让你
我的世界基岩版1.16正式版
我的世界基岩版是一款模拟经营手游,游戏采用的是经典像素玩法,
早安我的少年最新版2024
早安我的少年是一款养成恋爱手游,在这款游戏中,玩家们将可以体