public sub exptoexcel(lvwlist as listview)
dim i as long
dim newapp as new excel.application
dim newbook as new excel.workbook
dim newsheet as new excel.worksheet
set newapp = new excel.application
set newbook = newapp.workbooks.add
set newsheet = newbook.worksheets(1)
if lvwlist.listitems.count = 0 then exit sub
dim arrdata() as string
redim arrdata(0 to lvwlist.listitems.count, 0 to lvwlist.columnheaders.count) as string
dim j as integer
for j = 1 to lvwlist.columnheaders.count
arrdata(0, j - 1) = lvwlist.columnheaders(j).text
next
for i = 1 to lvwlist.listitems.count
arrdata(i, 0) = lvwlist.listitems(i).text
for j = 1 to lvwlist.columnheaders.count - 1
arrdata(i, j) = lvwlist.listitems(i).subitems(j)
next
next
newsheet.range(newsheet.cells(1, 1), newsheet.cells(i, j)) = arrdata
newsheet.columns.autofit
newapp.visible = true
set newsheet = nothing
set newbook = nothing
set newapp = nothing
end sub