Bajar GRIDS de Visual Fox en varias hojas EXCEL

Hola Alonso, que tal, solicitando tu ayuda nuevamente con un tema de FOX, en un formulario de fox tengo 4 grids, cada uno en una página de un Pageframe, quisiera poder bajar cada grid en una hoja de un mismo archivo de Excel (Hoja1, Hoja2, Hoja3, Hoja4) y si es posible que cada hoja tenga el nombre de la página del Pageframe. De antemano muchas gracias por tu ayuda.

1 respuesta

Respuesta
1
Es sencillo seleccionas cada que está enlazada a cada grilla y haces algo como lo siguiente:
Select Agenda && Nombre de la tabla seleccionada.
MsExcel = Createobject("Excel.Application")
If Type("MsExcel") = "O" Then
MsExcel.Visible = .T. && Esta línea se coloca para ver si llega los datos no es recomendable colocarla.
MsExcel.Workbooks.Add()
MsExcel.Worksheets(1).Name = "Visual FoxPro" && el índice 1 indica el orden sucesivo de las hojas en excel y la propiedad Name sirve para cambiar el nombre de la hoja de Excel.
WkpGxtab = MsExcel.ActiveSheet
With WkpGxtab.Range(WkpGxtab.Cells(3,1), WkpGxtab.Cells(3,4))
.Borders.LineStyle = 7
.Borders(1).Weight = 3
.Borders(2).Weight = 3
.Borders(3).Weight = 3
.Borders(4).Weight = 3
.Font.Bold = .T.
.Font.ColorIndex = 5
.Interior.ColorIndex = 4
.HorizontalAlignment = 3
.VerticalAlignment = 2
Endwith
WkpGxtab.Range("A1").Select
WkpGxtab.Cells(1,1).Value = "Datos de Visual FoxPro"
WkpGxtab.Cells(3,1).Value = "Código"
WkpGxtab.Cells(3,2).ColumnWidth = 30
WkpGxtab.Cells(3,2).Value = "Nombre"
WkpGxtab.Cells(3,3).ColumnWidth = 40
WkpGxtab.Cells(3,3).Value = "Apellido"
WkpGxtab.Cells(3,4).ColumnWidth = 20
WkpGxtab.Cells(3,4).Value = "Teléfono"
lcRec = Reccount()
For i = 1 to lcRec
Go i
WkpGxtab.Range(WkpGxtab.Cells(i+3,1), WkpGxtab.Cells(i+3,4)).Select
WkpGxtab.Cells(i+3,1).Value = friend_id
WkpGxtab.Cells(i+3,2).Value = friend_las
WkpGxtab.Cells(i+3,3).Value = friend_nam
WkpGxtab.Cells(i+3,4).Value = friend_pho
With WkpGxtab.Range(WkpGxtab.Cells(i+3,1), WkpGxtab.Cells(lcRec+3,4))
.Borders.LineStyle = 7
.Borders(1).Weight = 2
.Borders(2).Weight = 2
.Borders(3).Weight = 2
.Borders(4).Weight = 2
Endwith
Endfor
Este ejemplo de código te puede servir de mucha ayuda, cualquier inquietud me la haces saber.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas