excel导入代码出错
我用excel的数据导入到表格中
Dim objExcel As New Excel.Application, objWorkBook As Excel.Workbook, objSeet As Excel.Worksheet
Set objWorkBook = objExcel.Workbooks.Open(App.Path & "\yourData.xls ") '把 App.Path & "\yourData.xls " 改为你的excel文件路径
Set objSeet = objWorkBook.Sheets( "Sheet1 ")
for i=objseet.rows
for j=objseet.columns
gird1.textmatrix(i,j)=objseet.cells(i,j)
objWorkBook.Close
Set objExcel = Nothing
可是这样会出错
[解决办法]
你这个是VB代码么??基础很重要哦
for i=1 to objseet.rows
for j= 1 to objseet.columns
gird1.textmatrix(i,j)=objseet.cells(i,j)
next
next
[解决办法]
waiwai1015,你好,请问是什么错误呢?
顺便说一下,赋值的时候最好使用Cells.Value, 不要直接用cells这个object
gird1.textmatrix(i,j)=objseet.cells(i,j).Value
[解决办法]
dim i as long ,j as long
for i=1 to objseet.rows.Count
for j= 1 to objseet.columns.Count
gird1.textmatrix(i,j)=objseet.cells(i,j).value
next j
next i
[解决办法]