1个回答
展开全部
在项目中添加Excel类库的引用,然后在VB中定义Excel 的Application,WorkBook和Worksheet
然后对Worksheet中的Range进行操作,不用像Access那样建立ADO什么的连接。
比如
Dim exlApp as Excel.Application = Createobject("Excel.Application")
if exlApp is Nothing then exit sub
dim xBook as Excel.WorkBook=exlApp.Workbook.add
if xBook is Nothing then exit sub
dim xSheet as excel.WorkSheet =xbook.WorkSheet.Add
if xSheet is Nothing Then exit sub
with xSheet
.Range("A1").value="Excel Application Test"
.Range("B1" & ":D2").Merge
.Range("B1" & ":D2").Value="合并表格内容"
end with
你可以试试连接是否正确。
然后对Worksheet中的Range进行操作,不用像Access那样建立ADO什么的连接。
比如
Dim exlApp as Excel.Application = Createobject("Excel.Application")
if exlApp is Nothing then exit sub
dim xBook as Excel.WorkBook=exlApp.Workbook.add
if xBook is Nothing then exit sub
dim xSheet as excel.WorkSheet =xbook.WorkSheet.Add
if xSheet is Nothing Then exit sub
with xSheet
.Range("A1").value="Excel Application Test"
.Range("B1" & ":D2").Merge
.Range("B1" & ":D2").Value="合并表格内容"
end with
你可以试试连接是否正确。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询