Visual Basic - Pasar de MSflexgrid a Excel

Life is soft - evento anual de software empresarial
 
Vista:

Pasar de MSflexgrid a Excel

Publicado por Palma's (3 intervenciones) el 07/11/2007 22:58:11
Hola, Espero y me puedan ayudar.

Realmente lo que quiero hace es que tengo un Flexgrid y quiero que cuando presione un boton me genere un archivo de excel con la informacion que tengo en el Flexgrid.

Espero su ayuda....
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:Pasar de MSflexgrid a Excel

Publicado por ryo007 (1 intervención) el 11/11/2007 21:37:49
Aca te pego el fragmento que pasa un flexgrid a Excel.

Private Sub Command1_Click()
Rem ****************************************************************
Rem * Abro el Excel
Rem ****************************************************************

Dim Planillatemporal As Object
Set Planillatemporal = GetObject("", "excel.sheet")
ExcelApp = Planillatemporal.Application

Planillatemporal.Application.Visible = True
Planillatemporal.Application.Workbooks.Add

Rem ****************************************************************
Rem * Cargo Celdas
Rem ****************************************************************

If Option3.Value Then
Planillatemporal.Application.Cells(1, 2).Value = "Planilla de IVA Ventas
" + LTrim(RTrim(cmesperiodo.Text)) + " - " + LTrim(RTrim(canoperiodo.Text))
Else
Planillatemporal.Application.Cells(1, 1).Value = "cliente"
Planillatemporal.Application.Cells(2, 1).Value = "Domicilio"
Planillatemporal.Application.Cells(3, 1).Value = "Localidad"
Planillatemporal.Application.Cells(4, 1).Value = "Provincia"
Planillatemporal.Application.Cells(5, 1).Value = "Pais"
Planillatemporal.Application.Cells(6, 1).Value = "Telefonos"
Planillatemporal.Application.Cells(7, 1).Value = "C.U.I.T."

Planillatemporal.Application.Cells(1, 2).Value = "(" +
LTrim(RTrim(ccodcliente.Text)) + ")" + cnomcliente.Text
Planillatemporal.Application.Cells(2, 2).Value = cdomcliente.Text
Planillatemporal.Application.Cells(3, 2).Value = tloccliente.Text
Planillatemporal.Application.Cells(4, 2).Value = tprocliente.Text
Planillatemporal.Application.Cells(5, 2).Value = tpaicliente.Text
Planillatemporal.Application.Cells(6, 2).Value = ctelcliente.Text
Planillatemporal.Application.Cells(7, 2).Value = ccuicliente.Text

Planillatemporal.Application.Cells(1, 3).Value = "Vendedor"
Planillatemporal.Application.Cells(2, 3).Value = "Cobrador"
Planillatemporal.Application.Cells(3, 3).Value = "Zona"
Planillatemporal.Application.Cells(4, 3).Value = "SubZona"
Planillatemporal.Application.Cells(5, 3).Value = "Tipo de Cliente"
Planillatemporal.Application.Cells(6, 3).Value = "Tipo de Comprador"
Planillatemporal.Application.Cells(7, 3).Value = "Tipo de Deudor"

Planillatemporal.Application.Cells(1, 4).Value = cdetvendedor.Text
Planillatemporal.Application.Cells(2, 4).Value = cdetcobrador.Text
Planillatemporal.Application.Cells(3, 4).Value = cdetzona.Text
Planillatemporal.Application.Cells(4, 4).Value = cdetsubzona.Text
Planillatemporal.Application.Cells(5, 4).Value = cdetTipodeCliente.Text
Planillatemporal.Application.Cells(6, 4).Value =
cdetTipodeComprador.Text
Planillatemporal.Application.Cells(7, 4).Value = cdetTipodeDeudor.Text

Planillatemporal.Application.Cells(1, 6).Value = "Desde"
Planillatemporal.Application.Cells(2, 6).Value = "Hasta"

Planillatemporal.Application.Cells(1, 7).Value = Dpdesde.Value
Planillatemporal.Application.Cells(2, 7).Value = dphasta.Value
End If

col_auxi = gfichas.Cols
fil_auxi = gfichas.Rows

con_colu = 0
Do While con_colu < col_auxi - IIf(Option3.Value, 0, 1)
con_fila = 0
Do While con_fila < fil_auxi
gfichas.Col = con_colu
gfichas.Row = con_fila
If Option3.Value Then
If gfichas.Col > 3 And gfichas.Row <> 0 Then
Planillatemporal.Application.Cells(3 + con_fila + 1,
con_colu + 1).Value = funciones.mivalornumerico(gfichas.Text)
Else
Planillatemporal.Application.Cells(3 + con_fila + 1,
con_colu + 1).Value = gfichas.Text
End If
Else
If gfichas.Col > 1 And gfichas.Col < 5 And gfichas.Row <> 0 Then
Planillatemporal.Application.Cells(9 + con_fila + 1,
con_colu + 1).Value = funciones.mivalornumerico(gfichas.Text)
Else
Planillatemporal.Application.Cells(9 + con_fila + 1,
con_colu + 1).Value = gfichas.Text
End If
End If
con_fila = con_fila + 1
Loop
con_colu = con_colu + 1
Loop
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