最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net 读取Excel数据
时间:2022-06-25 05:06:39 编辑:袖梨 来源:一聚教程网
asp教程.net 读取excel数据
<%@ page language="vb" autoeventwireup="false" codefile="excel.aspx.vb" inherits="_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
%>
相关文章
- 《尼尔:机械纪元》武器黑之倨傲属性及特殊能力介绍 11-15
- 《尼尔:机械纪元》机械生命体的枪获得方法介绍 11-15
- 《尼尔:机械纪元》武器机械生命体的枪属性及特殊能力介绍 11-15
- 《尼尔:机械纪元》天使之圣翼获得方法介绍 11-15
- 《尼尔:机械纪元》武器天使之圣翼属性及特殊能力介绍 11-15
- 《尼尔:机械纪元》武器恶魔之秽牙属性及特殊能力介绍 11-15