Para exportar a Excel, puedes seguir los siguientes pasos:
1). Salvas el DW como HTML.
2). Luego utilizando OLE, para conectarte a Excel y hacerle un Export.
Aquí te dejo unos objetos que hace la exportación, primero el que habre las hojas de Excel.
$PBExportHeader$f_abrir_hojacalculo.srf
global type f_abrir_hojacalculo from function_object
end type
forward prototypes
global function integer f_abrir_hojacalculo (long al_documento, string as_nombredocumentoexistente, string as_salvarcomo)
end prototypes
global function integer f_abrir_hojacalculo (long al_documento, string as_nombredocumentoexistente, string as_salvarcomo);Constant long cll_DocumentoNuevo=1
Constant long cll_DocumentoExistente=2
Constant long cll_DocumentoFormato=3
string ls_ArchivoExistente
long ll_retorno
OLEObject ExcelApp
ExcelApp=CREATE OLEObject
ll_retorno=ExcelApp.ConnectToNewObject("excel.application")
If ll_retorno <> 0 Then
MessageBox("Atención", "No se pudo establecer la conexión con Excel.")
DESTROY ExcelApp
RETURN 1
End If
If (al_Documento = cll_DocumentoNuevo) Then
// Generar un documento totalmente nuevo
ExcelApp.WorkBooks.Add
// Si genera un documento nuevo siempre edita el mismo
ElseIf (al_Documento = cll_DocumentoExistente) or &
(al_Documento = cll_DocumentoFormato) Then
// Generar un documento nuevo a partir de uno existente
// o almacenado como formato
ls_ArchivoExistente=as_NombreDocumentoExistente
// Verificar que el archivo exista
If Not FileExists(ls_archivoexistente) Then
MessageBox("Atención!", "El documento que se especificó no existe.")
DESTROY ExcelApp
RETURN -1
ElseIf FileExists(f_obtener_archivo_bloqueado(as_NombreDocumentoExistente)) then
MessageBox("Atención!", "El archivo que seleccionó ya está siendo utilizado por otro programa, no es posible cargarlo hasta que cierre el programa que lo está utilizando.")
DESTROY ExcelApp
RETURN -1
End If
End If
// Cargar un documento existente
ExcelApp.WorkBooks.Open(ls_ArchivoExistente)
ExcelApp.Visible=TRUE
If len(as_salvarcomo) > 0 Then &
ExcelApp.ActiveWorkBook.SaveAs(as_salvarcomo, -4143, "", "", FALSE, FALSE)
DESTROY ExcelApp
RETURN 1
end function
-------------------------------------------------------------------------------------------
Ahora el objeto que exporta a Excel. Hay que pegarlo a la ventana dónde se vaya a usar y llamar la función of_enviarexcel , enviando como parámetro el DW que se desea exportar.
$PBExportHeader$corp_n_cst_dwsrv_enviaexcel.sru
$PBExportComments$ext_mw_objuser.pbl
forward
global type corp_n_cst_dwsrv_enviaexcel from n_cst_dwsrv
end type
end forward
global type corp_n_cst_dwsrv_enviaexcel from n_cst_dwsrv autoinstantiate
end type
forward prototypes
public subroutine of_enviarexcel (ref u_dw au_dw)
end prototypes
public subroutine of_enviarexcel (ref u_dw au_dw);String docname, named
Integer value
Long ll_archivos
OLEObject myoleobject
value=GetFileSaveName("Defina el nombre de la hoja a generar", docname, named, "XLS",'Excel (*.XLS), *.XLS')
SetPointer(HourGlass!)
If value > 0 Then
FileDelete(docname)
If au_dw.SaveAs(docname, HTMLTable!, FALSE) = -1 Then
MessageBox("ERROR", "Problema exportando reporte a Excel", StopSign!)
RETURN
End If
myoleobject=CREATE OLEObject
If myoleobject.ConnectToObject(docname) = 0 Then
ll_archivos= myoleobject.application.workbooks.Count
myoleobject.application.DisplayAlerts=FALSE
myoleobject.application.workbooks(ll_archivos).Parent.Windows(myoleobject.application.workbooks(ll_archivos).Name).Visible=TRUE
myoleobject.application.workbooks(ll_archivos).SaveAs(docname, 39)
If ll_archivos= 1 Then
myoleobject.application.Quit()
Else
myoleobject.application.workbooks(ll_archivos).Close()
End If
myoleobject.DisconnectObject()
Else
MessageBox("Información!", "No hay Explorador... ", StopSign!)
End If
DESTROY myoleobject
SetPointer(Arrow!)
MessageBox("Mensaje", "Exportación de Datos a Excel ejecutada satisfactoriamente... ", StopSign!)
SetPointer(HourGlass!)
f_Abrir_HojaCalculo(2, docname, '')
End If
SetPointer(Arrow!)
end subroutine
on corp_n_cst_dwsrv_enviaexcel.create
TriggerEvent( this, "constructor" )
end on
on corp_n_cst_dwsrv_enviaexcel.destroy
TriggerEvent( this, "destructor" )
end on