你太厉害了!!!
Private Sub Command6_Click()
If Me.ListView1.ListItems.Count = 0 Then Exit Sub
= False
On Error Resume Next
Dim xlApp As Object, Wb As Object, i&, j&, T&, h&, ar()
T = ListView1.ListItems.Count
h = ListView1.ColumnHeaders.Count
If T = 0 Then Exit Sub
DoEvents
Set xlApp = CreateObject("Excel.Application")
If xlApp Is Nothing Then
MsgBox "pls install Microsoft Excel."
Exit Sub
Else
ReDim ar(1 To T + 1, 1 To h)
For i = 1 To h
ar(1, i) = ListView1.ColumnHeaders(i)
Next
For i = 2 To T + 1
ar(i, 1) = ListView1.ListItems(i - 1)
For j = 1 To h
ar(i, j + 1) = ListView1.ListItems(i - 1).SubItems(j)
Next
Next
Set Wb = xlApp.Workbooks.Add
Wb.ActiveSheet.Range("A:AA").NumberFormatLocal = "@"
Wb.ActiveSheet.Range("a1").Resize(UBound(ar), h) = ar
Wb.ActiveSheet.Cells.Columns.AutoFit
xlApp.Visible = True
Set Wb = Nothing
Set xlApp = Nothing
= True
End If
End Sub
[此贴子已经被作者于2016-1-28 10:53编辑过]