title: How to Export All the data of listview with its header to excel sheet in vb 6.0
body: <p>I am exporting all the data of a ListView control to an Excel sheet, in VB 6.0.</p>
  
  <p>My code is below:</p>
  
  <pre><code>Private Sub cmdExport_Click()
  
  'general
  Dim objExcel As New Excel.Application
  
   Dim objExcelSheet As Excel.Worksheet
  '-----------------------------------
  
  'check whether data is there
   If LstLog.ListItems.count &gt; 0 Then
  objExcel.Workbooks.Add
  Set objExcelSheet = objExcel.Worksheets.Add
  
  
  For Col = 1 To LstLog.ColumnHeaders.count
      objExcelSheet.Cells(1, Col).Value = LstLog.ColumnHeaders(Col)
  Next
  
  For Row = 2 To LstLog.ListItems.count
      For Col = 1 To LstLog.ColumnHeaders.count
      If Col = 1 Then
              objExcelSheet.Cells(Row, Col).Value = LstLog.ListItems(Row).Text
      Else
              objExcelSheet.Cells(Row, Col).Value = LstLog.ListItems(Row).SubItems(Col - 1)
      End If
      Next
   Next
  
  objExcelSheet.Columns.AutoFit
  CommonDialog1.ShowOpen
  A = CommonDialog1.FileName
  
  objExcelSheet.SaveAs A &amp; ".xls"
  MsgBox "Export Completed", vbInformation, Me.Caption
  
  objExcel.Workbooks.Open A &amp; ".xls"
  objExcel.Visible = True
  'objExcel.Quit
  Else
  MsgBox "No data to export", vbInformation, Me.Caption
  End If
  
  End Sub
  </code></pre>
  
  <p>The problem is that the first row from the ListView is covered by text from the ListView  header.</p>