if thisform.chkSoloProductoCant.value = 0
local Fila && Prepara la hoja de excel
wait'Espere Un Momento Exportando Datos' window nowait
_screen.mousepointer=14
TmpSheet = CreateObject('Excel.Application')
*// TmpSheet=getobject('','Excel.Sheet')
XLApp=TmpSheet.application
XLApp.visible=.t.
XLApp.workbooks.add()
XLSheet=XLApp.ActiveSheet
*// encabezados del libro en excel *//
XLSheet.Cells(4,1)="Código"
XLSheet.Cells(4,1).font.bold=.t.
XLSheet.Cells(4,1).font.size="9"
XLSheet.Cells(4,1).font.name="Arial"
XLSheet.Cells(4,2)="Articulo"
XLSheet.Cells(4,2).font.bold=.t.
XLSheet.Cells(4,2).font.size="9"
XLSheet.Cells(4,2).font.name="Arial"
XLSheet.Cells(4,3)="Cant."
XLSheet.Cells(4,3).font.bold=.t.
XLSheet.Cells(4,3).font.size="9"
XLSheet.Cells(4,3).font.name="Arial"
sele 1
Fila=5
do case && Verifica la forma de seleccionar los datos para ser enviados
case thisform.Optiongroup1.value = 1 && Marzam
select Articulos_a_solicitar.exp_1,;
Articulos_a_solicitar.descrip,;
Articulos_a_solicitar.exp_5;
from Articulos_a_solicitar;
where Articulos_a_solicitar.pedir = .t. into cursor dEnv
select dEnv && Envia los datos
go top
scan
XLSheet.Cells(Fila,1)=alltrim(dEnv.exp_1)
XLSheet.Cells(Fila,2)=alltrim(dEnv.descrip)
XLSheet.Cells(Fila,3)=dEnv.exp_5
Fila=Fila+1
endscan
case thisform.Optiongroup1.value = 2 && Nadro
select Articulos_a_solicitar.code_nadro,;
Articulos_a_solicitar.descrip,;
Articulos_a_solicitar.exp_5;
from Articulos_a_solicitar;
where Articulos_a_solicitar.pedir = .t. into cursor dEnv
select dEnv && Envia los datos
go top
scan
XLSheet.Cells(Fila,1)=alltrim(dEnv.code_nadro)
XLSheet.Cells(Fila,2)=alltrim(dEnv.descrip)
XLSheet.Cells(Fila,3)=dEnv.exp_5
Fila=Fila+1
endscan
case thisform.Optiongroup1.value = 3 && otros
select Articulos_a_solicitar.cve_prov,;
Articulos_a_solicitar.descrip,;
Articulos_a_solicitar.exp_5;
from Articulos_a_solicitar;
where Articulos_a_solicitar.pedir = .t. into cursor dEnv
select dEnv && Envia los datos
go top
scan
XLSheet.Cells(Fila,1)=alltrim(dEnv.cve_prov)
XLSheet.Cells(Fila,2)=alltrim(dEnv.descrip)
XLSheet.Cells(Fila,3)=dEnv.exp_5
Fila=Fila+1
endscan
endcase
else
local Fila && Prepara la hoja de excel
wait'Espere Un Momento Exportando Datos' window nowait
_screen.mousepointer=14
TmpSheet=getobject('','Excel.Sheet')
XLApp=TmpSheet.application
XLApp.visible=.t.
XLApp.workbooks.add()
XLSheet=XLApp.ActiveSheet
XLSheet.Cells(4,1)="Articulo"
XLSheet.Cells(4,1).font.bold=.t.
XLSheet.Cells(4,1).font.size="9"
XLSheet.Cells(4,1).font.name="Arial"
XLSheet.Cells(4,2)="Cant."
XLSheet.Cells(4,2).font.bold=.t.
XLSheet.Cells(4,2).font.size="9"
XLSheet.Cells(4,2).font.name="Arial"
XLSheet.Cells(4,4)="Articulo"
XLSheet.Cells(4,4).font.bold=.t.
XLSheet.Cells(4,4).font.size="9"
XLSheet.Cells(4,4).font.name="Arial"
XLSheet.Cells(4,5)="Cant."
XLSheet.Cells(4,5).font.bold=.t.
XLSheet.Cells(4,5).font.size="9"
XLSheet.Cells(4,5).font.name="Arial"
sele 1
Fila=5
select Articulos_a_solicitar.descrip,;
Articulos_a_solicitar.exp_5;
from Articulos_a_solicitar;
where Articulos_a_solicitar.pedir = .t. into cursor dEnv
*// comienza el envio de datos a nuetro libro en excel *//
select dEnv
go top
scan
*// la siguiente condicion, mand el informe en dos columnas
*//
if mod(recno(), 2) = 0
*// para un registro par *//
XLSheet.Cells(Fila,4)=alltrim(dEnv.descrip)
XLSheet.Cells(Fila,5)=dEnv.exp_5
Fila=Fila+1
else
*// para un registro primo *//
XLSheet.Cells(Fila,1)=alltrim(dEnv.descrip)
XLSheet.Cells(Fila,2)=dEnv.exp_5
XLSheet.Cells(Fila,3)="---"
Fila=Fila
endif
endscan
endif
*//;
Ajusta Las celdas al tamaño de los datos;
*//
XLSheet.columns("A:A").EntireColumn.autofit
XLSheet.columns("B:B").EntireColumn.autofit
XLSheet.columns("C:C").EntireColumn.autofit
XLSheet.columns("D:D").EntireColumn.autofit
XLSheet.columns("E:E").EntireColumn.autofit
XLSheet.columns("F:F").EntireColumn.autofit
*// Datos de la hoja, despues de ajustar las columnas;
para evitar que se ajuste a los nuevos campos;
*//
set date long
XLSheet.Cells(1,1)="Fecha: " + dtoc(date())
XLSheet.Cells(1,1).font.bold=.t.
XLSheet.Cells(1,1).font.size="11"
XLSheet.Cells(1,1).font.name="Arial"
set date short
_screen.mousepointer=0