Visual Basic - Exportar a excel

Life is soft - evento anual de software empresarial
 
Vista:

Exportar a excel

Publicado por AzureSky (3 intervenciones) el 06/11/2008 14:57:21
Hola a todos, quisiera saber si alguno sabe donde puedo conseguir un manual completo sobre como usar la exportacion de datos a excel desde Visual Basic 6. Estoy trabajando con un programa que ya tiene algunas cosas implementadas, pero no todas y quisiera expandirlo mas, pero no logo encontrar informacion sobre cosas basicas como por ejemplo agregar hojas a un archivo, poner comentario en alguna celda, etc. Si alguien sabe donde puedo encontrar esta y mas informacion sobre el tema se los agradeceria enormemente.

Saludos y Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Exportar a excel

Publicado por quique (63 intervenciones) el 06/11/2008 15:49:04
yo sé donde puedes encontrar esa información y mas...

¡¡¡¡¡ EN EL GUGUEL !!!!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Exportar a excel

Publicado por AzureSky (3 intervenciones) el 06/11/2008 16:26:20
Gracias por responder, pero ya he buscado por ahi y lo unico que encontre son manuales para usar codigo de visual basic pero dentro del excel y no para exportar de visual a excel.
Agradezco que te hayas tomado el tiempo de responder pero de hacerlo nuevamente agradeceria no menospreciarme, si estoy preguntando aca si alguen sabe donde puedo encontrar dicha informacion es porque no la encuento y no porque no tengo ganas de buscarla.

Nuevamente gracias y espero alguien pueda orientar mi busqueda.

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de rtb

RE:Exportar a excel

Publicado por rtb (6 intervenciones) el 06/11/2008 21:39:38
mira por ahi:
http://www.recursosvisualbasic.com.ar/htm/tutoriales/excel.htm
tiene muchos ejemplos..

http://www.canalvisualbasic.net/

Espero te sirva...
saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Exportar a excel

Publicado por quique (63 intervenciones) el 06/11/2008 23:08:35
que no!
qu el tio ya ha buscado por todos los sitios y no encuentra nada, así que no le des direcciones

porqué crees que pregunta aquí? él mismo te lo explica en el post anterior!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Exportar a excel

Publicado por Omar (56 intervenciones) el 07/11/2008 00:06:00
Un fragmento de como exportar a exel...

Rango = "a1:c1")
'Negrita
libro.Range("a3").Font.Bold = True
'Unir varias celdas
libro.Range("a1:c1").Merge
'Borde a las celdas
libro.Range(Rango).Borders.LineStyle = 1
'Cambiar color a la celda
libro.Range(rango).Interior.ColorIndex = 6
'centrar el texto
libro.Range(rango).HorizontalAlignment = xlCenter
'ajustar las columnas al texto
libro.Columns.AutoFit
'definir ancho de columna
libro.Range("c1").ColumnWidth = 35
'ajustar texto a ancho de columna
libro.Columns.WrapText = True
'formato a celdas
libro.Range(Rango2).NumberFormat = "#,##0.00"
'borrar contenido de celda
libro.Range(Rango2).Clear
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Me equivoque, pero este si exporta...

Publicado por Omar (56 intervenciones) el 07/11/2008 20:29:17
Private Sub ExportaPlacas()
Dim xlApli As Object
Dim xlLibro As Excel.Workbook
Dim FilaFlex As Integer
Dim FilaExcel As Integer

Set xlApli = New Excel.Application
Set xlLibro = xlApli.Workbooks.Add
''''''''''''''''''''''''''''''''''''''''''''''''''
With xlApli
.Sheets(1).Activate

FilaExcel = 10

.Range("A1:E1").Font.Size = 12
.Range("A1:E1").Font.Name = "Times New Roman"
.Range("A1:E7").Font.Bold = True
.Range("A1:E7").Font.Italic = True
.Range("A8:E8").Borders.LineStyle = 1
.Range("A8:E8").Interior.ColorIndex = 6
.Range("A8:E8").HorizontalAlignment = xlCenter
.Range("A1:E1").Select
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With xlApli.Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With xlApli.Selection
.Merge
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With xlApli.Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With xlApli.Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With xlApli.Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With xlApli
.Sheets(1).Activate
.Range("A1") = "LISTADO DE SERVICIOS POR PLACAS"
.Range("A3") = "CLIENTE :"
.Range("B3") = CBONOMBRE.Text
.Range("A5") = "FECHA :"
.Range("B5") = Date
.Range("A6") = "HORA :"
.Range("B6") = Time
.Range("A8") = "PLACAS"
.Range("A10") = MSFlexGrid1.TextMatrix(1, 2)
.Range("B8") = "FECHA SERVICIO"
.Range("C8") = "MARCA"
.Range("D8") = "KILOMETRAJE"
.Range("E8") = "DETALLE SERVICIO"
End With

With MSFlexGrid1
For FilaFlex = 1 To .Rows - 1
xlApli.Cells(FilaExcel, 2) = .TextMatrix(FilaFlex, 1)
xlApli.Cells(FilaExcel, 3) = .TextMatrix(FilaFlex, 3)
xlApli.Cells(FilaExcel, 4) = .TextMatrix(FilaFlex, 4)
xlApli.Cells(FilaExcel, 5) = .TextMatrix(FilaFlex, 5)
FilaExcel = FilaExcel + 1
Next
End With
xlApli.Columns.AutoFit

With xlApli
.Sheets(1).Activate
Columns("B:B").ColumnWidth = 24
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With xlApli.ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.196850393700787)
.RightMargin = Application.InchesToPoints(0.196850393700787)
.TopMargin = Application.InchesToPoints(0.393700787401575)
.BottomMargin = Application.InchesToPoints(0.393700787401575)
.CenterHorizontally = True
.Orientation = xlLandscape
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
xlApli.Visible = True
Set xlApli = Nothing
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:desde vb a excel...

Publicado por HUGO NARVAEZ (1 intervención) el 29/12/2008 20:21:59
primero se tiran los datos a un datagrid
despues se aplica el sgte:codigo


n_Filas = Me.datagrid_articulos_mensual.ApproxCount
On Error GoTo ErrSub
Dim i As Integer, j As Integer
If n_Filas = 0 Then
MsgBox "No hay datos para exportar a excel": Exit Sub
Else
Set Obj_Excel = CreateObject("Excel.Application")
Set Obj_Libro = Obj_Excel.Workbooks.Add
Set Obj_Hoja = Obj_Excel.ActiveSheet
Obj_Excel.Visible = True
iCol = 0
For i = 0 To Me.datagrid_articulos_mensual.Columns.Count - 1
If Me.datagrid_articulos_mensual.Columns(i).Visible Then
iCol = iCol + 1
Obj_Hoja.Cells(1, iCol) = Me.datagrid_articulos_mensual.Columns(i).Caption
For j = 0 To n_Filas - 1
Obj_Hoja.Cells(j + 2, iCol) = _
Me.datagrid_articulos_mensual.Columns(i).CellValue(Me.datagrid_articulos_mensual.GetBookmark(j))
Next
End If
Next
Obj_Hoja.Rows(1).Font.Bold = True
Obj_Hoja.Rows(1).Font.Color = vbRed
Obj_Hoja.Columns("A:Z").AutoFit
End If
Set Obj_Hoja = Nothing
Set Obj_Libro = Nothing
Set Obj_Excel = Nothing
Exit Sub
ErrSub:
MsgBox Err.Description, vbCritical
On Error Resume Next
Set Obj_Hoja = Nothing
Set Obj_Libro = Nothing
Set Obj_Excel = Nothing

espero te sirva
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:desde vb a excel...

Publicado por juan (1 intervención) el 19/06/2019 16:34:58
como harias esta operacion a la inversa osea importar datos de una hoja de excel al visual studio?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar