VB数据导出excel文件,总提示类型不对?
Withmyws.Range(.Cells(3,1),.Cells(3+i,11))=xlsapp.WorksheetFunction.Transpose(aPay)我要...
With myws
.Range(.Cells(3, 1), .Cells(3 + i, 11)) = xlsapp.WorksheetFunction.Transpose(aPay)
我要把数组转置导入excel表,这句总提示类型不对,什么原因呢?
Dim xlsapp As Excel.Application
Dim mywk As Excel.Workbook
Dim myws As Excel.Worksheet
Dim rng As Excel.Range
Dim i As Integer
Dim aPay
Adodc1.RecordSource = "select * from dacgj where 产品类别='复印纸'"
Adodc1.Refresh
aPay = Adodc1.Recordset.GetRows
Set xlsapp = New Excel.Application
xlsapp.Visible = True
Set mywk = xlsapp.Workbooks.Add("d:\00.xlt")
Set myws = mywk.Worksheets("产品")
i = UBound(aPay, 2)
With myws
.Range(.Cells(3, 1), .Cells(3 + i, 11)) = xlsapp.WorksheetFunction.Transpose(aPay)
Set rng = .Range(.Cells(2, 1), .Cells(3 + i, 11))
rng.Borders.LineStyle = xlContinuous
rng.RowHeight = 20
rng.EntireColumn.AutoFit
.PrintOut
End With
End Sub 展开
.Range(.Cells(3, 1), .Cells(3 + i, 11)) = xlsapp.WorksheetFunction.Transpose(aPay)
我要把数组转置导入excel表,这句总提示类型不对,什么原因呢?
Dim xlsapp As Excel.Application
Dim mywk As Excel.Workbook
Dim myws As Excel.Worksheet
Dim rng As Excel.Range
Dim i As Integer
Dim aPay
Adodc1.RecordSource = "select * from dacgj where 产品类别='复印纸'"
Adodc1.Refresh
aPay = Adodc1.Recordset.GetRows
Set xlsapp = New Excel.Application
xlsapp.Visible = True
Set mywk = xlsapp.Workbooks.Add("d:\00.xlt")
Set myws = mywk.Worksheets("产品")
i = UBound(aPay, 2)
With myws
.Range(.Cells(3, 1), .Cells(3 + i, 11)) = xlsapp.WorksheetFunction.Transpose(aPay)
Set rng = .Range(.Cells(2, 1), .Cells(3 + i, 11))
rng.Borders.LineStyle = xlContinuous
rng.RowHeight = 20
rng.EntireColumn.AutoFit
.PrintOut
End With
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询