主题:怎么样把SQL数据库里的表以Excel的文件读出
fearweki
[专家分:0] 发布于 2005-12-01 00:19:00
怎么样把SQL数据库里的表以Excel的文件读出
需要编写代码?如果需要怎么写?谢谢啦
回复列表 (共1个回复)
沙发
GBY [专家分:130] 发布于 2005-12-01 23:43:00
在代码前先添加microsoft Excel 10.0 Object Library组件的引用。
private sub button1_click(---)handles button1.click
dim xlApp as new excel.application
dim xlBook as excel.workbook
dim slSheet as excel.worksheet
dim rowIndex,colIndex as integer
rowIndex=1
colIndex=0
xlbook=xlapp.workbooks().add
xlsheet=xlbook.worksheets("sheet1")
dim Table as new datatable
table=creatable()
dim col as datacolumn
dim row as datarow
for each col in table.columns
colindex=colindex+1
xlapp.cells(1,colindex)=col.columnname
next
for each row in table.rows
rowindex=rowindex+1
colindex=0
for each col in table.columns
colindex=colindex+1
xlapp.cells(rowindex,colindex)=row(col.columnname)
next
next
end sub
我来回复