Event to add variable on demand

Hi, I need to process variables from a template because I am asking the user for the values at execution time. When I call the "Run" method, the program throws an exception due to undefined variables.

The configuration sheet includes a column titled "Report Variables" (Column K), but I couldn't find a method or property to consult these variables in the template.

Is it possible to include these variables in an event of the report? In the meantime, what is the best event to include the variables when processing the template?

Thanks for your help.

Hi,
The Report variables section in the config sheet is used for the designer, it won't help here.

If I understood correctly, I think you could use default values? See the second syntax here: FlexCel Reports Tag Reference. | FlexCel Studio for VCL and FireMonkey documentation

Say, if you write <#Date;> it will write the value of the report variable date if you defined, or nothing if you didn't. No exception should happen.

You also have a "defined" function that will allow you to do special stuff if a variable is not defined: FlexCel Reports Tag Reference. | FlexCel Studio for VCL and FireMonkey documentation

Finally, there is the preprocess tag: FlexCel Reports Tag Reference. | FlexCel Studio for VCL and FireMonkey documentation which you can use to convert those tags into others before running the report.

As said, I am not 100% sure I understood the question, if I didn't, please let me know.

Hi Adrian, thanks for your response. My primary language is spanish ( i'm from Colombia).

For you response, i think that i have to implement an algorithm to process the variables in Config sheet in the "BeforeReadTemplate" event, and then prompt and set the value of each variable.

The class FlexCelReport has the events "UserTable" and "LocalTable" for add data on demand.

Is possible to add an to Flexcel event to add variables on demand? for set values when i need.


Hola Adrian, gracias por tu respuesta.

Por tu respuesta, pienso que me toca implementar un algoritmo para procesar las variables de la hoja de configuración en el evento "BeforeReadTemplate" para preguntar y poner el valor a cada variable.

La clase FlexcelReport tiene los eventos "UserTable" y "LocalTable" para añadir los datos en demanda.

¿Es posible agregar un evento para añadir las variables en demanda? Para poner los valores según el uso.

No, Lamentablemente no tenemos un evento para preguntar las variables bajo demanda. Lo que podrias hacer para un caso asi es usar una UDF (funcion definida por el usuario). (Hay un ejemplo de como hacer una aqui: User defined functions (Delphi) | FlexCel Studio for VCL and FireMonkey documentation )

Entonces, si defines una UDF "Value" con un parametro que es el nombre de la variable, puedes escribir en la template:

<#value(valor1)>
<#value(valor2)>

Y la funcion sera llamada con el argumento "valor1" y "valor2" respectivamente. En ese momento puedes mostrar un dialogo al usuario y preguntar por el valor de la variable, y devolverlo en la UDF. Nota que si usas "valor1" mas de una vez, deberias guardar el valor para no preguntarlo 2 veces. (la segunda vez simplemente retornas lo que guardaste la primera vez)

Muchas gracias Adrian, voy a implementarlo como describes.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.