Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Impresión (https://www.clubdelphi.com/foros/forumdisplay.php?f=4)
-   -   sumar campos en rave report (https://www.clubdelphi.com/foros/showthread.php?t=89504)

identsoft 03-12-2015 10:14:29

sumar campos en rave report
 
tengo un report desarrollado con Rave Report. Los datos los extrae de una tabla de firebird. Mi pregunta es :¿como puedo sumar( dentro del report no en delphi) cuatro campos que estan en la tabla firebird? Y una vez sumados que se puedan imprimir con el formato numerico adecuado.
Ahora mismo, lo tengo hecho de la siguiente forma: en el evento on beforeprint de la banda hago la suma y la asigno a un datatext, pero no puedo verlo con el formato adecuado.
Con CalcOp no me sirve porque solo suma dos campos(al menos que yo sepa).
¿Como se podría hacer?
Gracias y un saludo para todos

Casimiro Notevi 03-12-2015 10:46:48

Cita:

Empezado por identsoft (Mensaje 500135)
Ahora mismo, lo tengo hecho de la siguiente forma: en el evento on beforeprint de la banda hago la suma y la asigno a un datatext, pero no puedo verlo con el formato adecuado.

Pues ponle el formato que quieras.

identsoft 03-12-2015 10:53:54

Perdon, no es un datatext, es un text component.
De todas formas en Rave Report la propiedad displayformat no esta ni en TextComponent ni en dataText component, está en cada campo del DataView.
Gracias casimiro

Casimiro Notevi 03-12-2015 10:58:14

Hace bastantes años que usé ravereport y se podía poner el formato, aunque no recuerdo cómo, la verdad :confused:
¿No tienes ningún ejemplo en la documentación? ¿Has buscado por los foros?

identsoft 03-12-2015 11:11:06

Cuando se trata de un campo, no hay problema, pero la cuestion es que esto es una operacion que hay que descargar sobre (en mi caso) un textcomponent y este componente no tiene la propiedad display format. Y sí, antes de preguntar aquí, he buscado en san google pero no he encontrado nada.

Casimiro Notevi 03-12-2015 11:22:11

A ver si te sirve algo de esto:
Cita:

Calculations to the Max

In addition to the simple CalcText component discussed earlier, the Rave Designer includes three components for handling more complex situations: CalcTotal, CalcController, and CalcOp.
CalcTotal

The CalcTotal is a non-visual version of the CalcText component. When this component is printed, its value is typically stored in a project parameter (defined by the DestParam property) and formatted according to the DisplayFormat property. It can be useful when you're performing totaling calculations that will be used by other calculations before being printed. If the value of the CalcTotal will only be used by other calculation components, such as CalcOp, you should leave the DestParam property blank.

CalcController

CalcController is a non-visual component that acts as a controller for CalcText and CalcTotal components through their Controller properties. When the controller component is printed, it signals all calculation components that it controls to perform their operation. This process allows a report to recalculate totals on group bands, detail bands, or whole pages depending upon the location of the CalcController component.
The CalcController component can also initialize a CalcText or CalcTotal component to a specific value (through the InitCalcVar, InitDataField, and InitValue properties). The CalcController component will initialize values only if it is used in the Initializer property of CalcText or CalcTotal components.

CalcOp

CalcOp is a non-visual component that allows an operation (defined by the Operator property) to be performed on values from different data sources. The result can then be saved in a project parameter like CalcTotal, as indicated by the DestParam and DisplayFormat properties.
For example, suppose you need to add two DataText components, as in A + B = C (where A and B represent the two DataText component values and C represents the result stored in a project parameter). The three source types have many different values associated with them.
The calculation can start with different types of data sources:
  • A DataField source is a field in a table, or a DataView in Rave terms. Thus in order to choose a field, you must first select a DataView.
  • For a Value source, you fill in the property with a numeric value.
  • A CalcVar source represents another calculation variable; you can choose one from the drop-down menu that lists all the calculation variables available in the page. This value can be from another CalcOp component or from some other calculation component.
After choosing the data sources, you select the operation to be used between them. The Operator property has a drop-down menu you can use to make the appropriate choice. In the example A + B = C, the operator is coAdd.
Sometimes a function needs to be performed on a value before it is processed with the second value. In this case the source's Function property is handy. With a function, you can converted a value (such as hours to minutes), compute a trigonometric function (like the sin of the value), or perform many others calculations (such as a square root or absolute value).
Just as it is important to do the calculations in order, it is important to make sure the components are in order in the Project Tree. A report executes components down the Project Tree. For CalcOp components or any calculation component, this means they must be in the correct order. It is also important to note that if a source value is dependent on any other components (like other CalcOp components or DataText components), those components must come first in the Project Tree.


identsoft 03-12-2015 12:30:47

Ya lo habia visto, pero el problema es que el CalOp solo suma dos campos y yo necesito sumar cuatro campos cada vez.
Una solucion seria CalcOp1(suma campo1 + campo2), CalcOp2(suma campo3 + campo4), CalcOp3(suma CalpOp1 + CalOp2).
Pero tiene que haber una solucion más sencilla.

hoyosfelix 12-01-2016 15:51:15

Respuesta a: sumar campos en rave report
 
Buen día,

Según tu 1º post ya puedes traer los campos de la base de datos, si es así te suguiero que sumes los campos necesarios y formatear dentro del Rave en el DisplayFormat: #,##0.##

Por otro lado, tengo entendido que en el evento before print ya te suma bien los campos pero no es posible formatear el campo en forma numérica; podrías probar formatear el resultado como en Delphi:

Código Delphi [-]
    QuerySUMA.DisplayFormat := '#,##0.##';

Saludos.
---
hoyosfelix


La franja horaria es GMT +2. Ahora son las 21:02:12.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi