怎样在vb中导入excel表格数据

2024-11-07 23:36:17
推荐回答(1个)
回答(1):

可以看vb自带的例子visdata,其中对txt文件和对excel文件的操作都有很详细的说明。
也可能通过以下方式:
引用micsosoft Excel x.0 object Library
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
FileCopy App.Path + "\rpf.xlt", App.Path + "\tmp.xlt"
FileName = App.Path + "\tmp.xls"
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(FileName)
xlApp.Visible = True
Set xlsheet = xlBook.Sheets("sheet1")
with xlsheet
.Cells(1, 1) =变量
end with