miércoles, 7 de octubre de 2020

Crear XLS /abrir XLS

 MyXLSDocumentToCreate is a xlsDocument

// Adds a worksheet
xlsAddWorksheet(MyXLSDocumentToCreate, "Customer list")
MyXLSDocumentToCreate..Worksheet = 1

// Adds a "title" row
MyXLSDocumentToCreate..Cell[1,1] = "Name"
MyXLSDocumentToCreate..Cell[1,1]..AlignmentH = haCenter
MyXLSDocumentToCreate..Cell[1,1]..Font..Bold = True
MyXLSDocumentToCreate..Cell[1,2] = "FirstName"
MyXLSDocumentToCreate..Cell[1,2]..AlignmentH = haCenter
MyXLSDocumentToCreate..Cell[1,2]..Font..Bold = True
MyXLSDocumentToCreate..Cell[1,3] = "Phone"
MyXLSDocumentToCreate..Cell[1,3]..AlignmentH = haCenter
MyXLSDocumentToCreate..Cell[1,3]..Font..Bold = True
MyXLSDocumentToCreate..Cell[1,4] = "Nb orders"
MyXLSDocumentToCreate..Cell[1,4]..AlignmentH = haCenter
MyXLSDocumentToCreate..Cell[1,4]..Font..Bold = True

// Adds data
FOR nCounter = 2 TO 50
    
    // Random data
    MyXLSDocumentToCreate..Cell[2,1] = "Name " + (nCounter-1)
    MyXLSDocumentToCreate..Cell[2,2] = "First name " + (nCounter-1)
    MyXLSDocumentToCreate..Cell[2,3] = "xx.xx.xx.xx.xx"
    MyXLSDocumentToCreate..Cell[2,4] = Random(0,50)
    // Applies a color according to the number of orders
    IF MyXLSDocumentToCreate..Cell[2,4] <= 5 THEN
        // Red
        MyXLSDocumentToCreate..Cell[2,4]..Font..Color = RGB(245, 110, 110)
    ELSE
        // Green
        MyXLSDocumentToCreate..Cell[2,4]..Font..Color = RGB(151, 221, 88)
    END
    
END

// Defines the path of the file to create
sNewFile is string = fTempPath()+["\"]+"XLSTest.xls"
// Saves the XLS document
IF xlsSave(MyXLSDocumentToCreate, sNewFile) = False THEN
    Error("Error while saving the document", ErrorInfo(errMessage))
    RETURN
END

// Closes the document (for its next opening)
xlsClose(MyXLSDocumentToCreate)

// Positions the file path in the edit control
EDT_XLSFile = sNewFile

// Runs the opening code
ExecuteProcess(TAB_Example.BTN_Open, trtClick)

 

 

 

////***** Abrir un documento xls  (2)

// Opens the XLS document
gMyXLSDocument = xlsOpen(EDT_XLSFile, xlsWrite)
IF ErrorOccurred THEN
    Error("Unable to open the document", ErrorInfo())
    RETURN
END

martes, 6 de octubre de 2020

Botón Browse

 // Open the vision window
IF Open(WIN_VISION_DB_Socio) = True THEN
    
    // Refresh the content of the DB_Socio combo box
    //    ListDisplay(COMBO_IdDB_Socio, taCurrentFirst)
    COMBO_IdSocio = DB_Socio.IdSocio
    STC_RazonSocial = DB_Socio.RazonSocial
    gdFechaNacimiento     = DB_Socio.FechaNacimiento
    
END

Botón con código para filtrar

 sMiFiltro is string
sFiltroFechas is string
sFiltroSolicitante is string
sFiltroArea is string
dFechaInicio is Date
dFechaFinal is Date

dFechaInicio = EDT_Date1
dFechaFinal  = EDT_Date2

//busco el id de cada parametro
IF COMBO_Solicitante..StoredValue <> "--TODOS--" THEN
    HReadSeekFirst(Solicitante, Solicitante.SolicitanteNombre, COMBO_Solicitante..StoredValue)
    IF HFound() = True
           sFiltroSolicitante =  " AND calendario.SolicitanteID = " + Solicitante.SolicitanteID
       ELSE
           sFiltroSolicitante = ""
    END
ELSE
    sFiltroSolicitante = ""
END

IF COMBO_Area..StoredValue <> "--TODOS--" THEN
    HReadSeekFirst(Area, AreaNombre, COMBO_Area..StoredValue)
    IF HFound() = True
        sFiltroArea = " AND calendario.AreaID = " +     Area.AreaID
    ELSE
        sFiltroArea = ""        
    END
ELSE
    sFiltroArea = ""    
END

sFiltroFechas = "Calendario.FechaProgramada >= " +  dFechaInicio  +  "  and Calendario.FechaProgramada <= " + dFechaFinal

//armo filtro
sMiFiltro = sFiltroFechas + sFiltroArea + sFiltroSolicitante

HFilter(Calendario,sMiFiltro)
HDeactivateFilter(Calendario)
HActivateFilter(Calendario)
TableDisplay(TABLE_Calendario,taStart)

Try catch end

 // -------------------------------------------------- // Procedure principal que executa uma query com tratamento de exceção // -----------...