#2
冬瓜汤2023-02-28 20:41
|
程序代码:
Private Sub Command3_Click()
Dim xla As Excel.Application 'Excel对象
Dim xlb As Excel.Workbook '工作簿
Dim xlss As Excel.Worksheet '工作表
Dim xlrange As Excel.Range
Dim i As Long
Dim j As Long
Dim savepath As String
Set xla = CreateObject("excel.application") '第一层
Set xlb = xlApp.Workbooks.Add
Set xlss = xlb.Worksheets(1)
xla.Visible = False
j = 2
For i = ListView1.ListItems.Count To 1 Step -1
xlss.Cells(j, 1) = ListView1.ListItems(i).Text
xlss.Cells(j, 2) = ListView1.ListItems(i).ListSubItems(1)
xlss.Cells(j, 3) = ListView1.ListItems(i).ListSubItems(2)
xlss.Cells(j, 4) = ListView1.ListItems(i).ListSubItems(3)
xlss.Cells(j, 5) = ListView1.ListItems(i).ListSubItems(4)
xlss.Cells(j, 6) = ListView1.ListItems(i).ListSubItems(5)
j = j + 1
Next
'xlb.Sheets(1).Range("a1") = "新建成功"
savepath = "D:\"
xlb.SaveAs savepath & "\领取记录.xls"
xlb.Close (True)
xla.Quit '关闭EXCEL
Set xla = Nothing '释放EXCEL对象
End Sub
Dim xla As Excel.Application 'Excel对象
Dim xlb As Excel.Workbook '工作簿
Dim xlss As Excel.Worksheet '工作表
Dim xlrange As Excel.Range
Dim i As Long
Dim j As Long
Dim savepath As String
Set xla = CreateObject("excel.application") '第一层
Set xlb = xlApp.Workbooks.Add
Set xlss = xlb.Worksheets(1)
xla.Visible = False
j = 2
For i = ListView1.ListItems.Count To 1 Step -1
xlss.Cells(j, 1) = ListView1.ListItems(i).Text
xlss.Cells(j, 2) = ListView1.ListItems(i).ListSubItems(1)
xlss.Cells(j, 3) = ListView1.ListItems(i).ListSubItems(2)
xlss.Cells(j, 4) = ListView1.ListItems(i).ListSubItems(3)
xlss.Cells(j, 5) = ListView1.ListItems(i).ListSubItems(4)
xlss.Cells(j, 6) = ListView1.ListItems(i).ListSubItems(5)
j = j + 1
Next
'xlb.Sheets(1).Range("a1") = "新建成功"
savepath = "D:\"
xlb.SaveAs savepath & "\领取记录.xls"
xlb.Close (True)
xla.Quit '关闭EXCEL
Set xla = Nothing '释放EXCEL对象
End Sub