vb6中读取EXCEL中数据写到文本中
读取EXCEL每行的一个单元格数据,然后前边加上序号,写到一个文本中,从EXCEL中读多少行就写多少行文本.......
读取EXCEL每行的一个单元格数据,然后前边加上序号,写到一个文本中,从EXCEL中读多少行就写多少行文本....
展开
1个回答
展开全部
Dim db As Database
Dim rs As Recordset
dim fn as integer
Set db = OpenDatabase("c:\myexcel.xls", False, False, "excel 8.0;HDR=YES")
Set rs = db.OpenRecordset(db.TableDefs(0).Name)
rs.movefirst
fn=freefile
open "mytext.txt" for append as fn
i=1
do while (not(rs.eof))
print #fn, i & chr(9) & rs("要输出的字段名") & vbCrlf
rs.movenext
loop
close fn
rs.close
db.close
Dim rs As Recordset
dim fn as integer
Set db = OpenDatabase("c:\myexcel.xls", False, False, "excel 8.0;HDR=YES")
Set rs = db.OpenRecordset(db.TableDefs(0).Name)
rs.movefirst
fn=freefile
open "mytext.txt" for append as fn
i=1
do while (not(rs.eof))
print #fn, i & chr(9) & rs("要输出的字段名") & vbCrlf
rs.movenext
loop
close fn
rs.close
db.close
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询