Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/10/2008, 12:54
evilesq
 
Fecha de Ingreso: octubre-2008
Mensajes: 11
Antigüedad: 15 años, 7 meses
Puntos: 0
Pregunta Como puedo exportar datos de un listview a execel

hola aqui de nuevo con un problemita que tengo, lo que pasa es que quiero pasar los datos de un listview a un archivo de excel en vb 2005

este es mi codigo pero me sale un error o mas bien no se como madar los datos que estan dentro del listview.


Option Explicit On
Imports System
Imports System.Reflection ' For Missing.Value and BindingFlags
Imports System.Runtime.InteropServices ' For COMException
Imports Microsoft.Office.Interop.Excel

Public Class FIteraciones

Private Sub GuardarToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuardarToolStripMenuItem1.Click

app = New Application()
If app Is Nothing Then
' MsgBox("ERROR: EXCEL couldn't be started!")
Environment.ExitCode = 0
Exit Sub
End If

'Console.WriteLine("Making application visible")
app.Visible = True

'MsgBox("Getting the workbooks collection")

workbooks = app.Workbooks
'MsgBox("Adding a new workbook")
Dim workbook As _Workbook
workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet)

'MsgBox("Getting the worksheets collection")
Dim sheets As Sheets
sheets = workbook.Worksheets

Dim worksheet As _Worksheet
worksheet = sheets.Item(1)
If worksheet Is Nothing Then
'MsgBox("ERROR: worksheet == null")
End If


Dim range3 As Object
Dim i As Integer
Dim aux As Integer
Dim aux1 As Integer
aux1 = Me.ListView1.Columns.Count
aux = Me.ListView1.Items.Count



range3 = worksheet.Range("A2", "C3")
Dim array3(aux, aux1) As Integer
Dim j As Integer
For i = 0 To aux 'CONTROL DE LAS FILAS
For j = 0 To aux1 'CONTROL DE LAS COLUMNAS
array3(i, j) = Me.CADENA3(i) <--- es aqui donde debo de mandar lo que tiene mi listview pero no se como ??

'i * 10 + j
Next j
Next i
range3.Value2 = array3




Environment.ExitCode = 100

End Sub


End Class