Member 10655931
Public Sub export_me_to_excel(ByVal list As ListView)
Try
Dim objExcel As New Excel.Application
Dim bkWorkBook As Workbook
Dim shWorkSheet As Worksheet
Dim chartRange As Excel.Range
Dim i As Integer
Dim j As Integer
objExcel = New Excel.Application
bkWorkBook = objExcel.Workbooks.Add
shWorkSheet = CType(bkWorkBook.ActiveSheet, Worksheet)
shWorkSheet.DisplayRightToLeft = True
chartRange = shWorkSheet.Range("a1", "e2")
chartRange.Merge()
chartRange.FormulaR1C1 = xlval
chartRange.HorizontalAlignment = 2
chartRange.VerticalAlignment = 2
For i = 0 To list.Columns.Count - 1
shWorkSheet.Cells(5, i + 1) = list.Columns(i).Text
shWorkSheet.Columns.AutoFit()
shWorkSheet.Columns.HorizontalAlignment = Excel.Constants.xlCenter
shWorkSheet.Columns.BorderAround(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex.xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic)
Next
For i = 0 To list.Items.Count - 1
For j = 0 To list.Items(i).SubItems.Count - 1
shWorkSheet.Cells(i + 6, j + 1) = list.Items(i).SubItems(j).Text
shWorkSheet.Columns.AutoFit()
shWorkSheet.Columns.HorizontalAlignment = Excel.Constants.xlCenter
shWorkSheet.Columns.BorderAround(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex.xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic)
Next
Next
objExcel.Visible = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Dave Kreskowiak
Итак, вы написали кусок кода и решили бросить его на все, что упоминает экспорт в Excel из ListView?
Необъяснимые ответы бесполезны.