Search code examples
jxls

Is it possible to set comment parameter from variable?


I'm migrating from jxls 1 and plan to use Grid. List of header will vary in the grid. Is it possible to set for example: formatCells parameter from variable passed in context?

Using excel comment:

context.putVar("contextVariable", "BigDecimal:C1,Date:D1");

jx:grid(lastCell="A4" headers="headers" data="data" areas=[A3:A3, A4:A4] formatCells=contextVariable)

If not, is Java API the recommended way to do this?

thanks, droggo


Solution

  • Usually there is no need to set formatCells attribute dynamically.

    This is because the order and the number of headers in your Grid does not matter in this case.. The Grid-command just reads all the available cell formats from the template and then finds the corresponding style for each grid cell by checking the data type (after cell evaluation) and mapping it to the list of cells passed in formatCells attribute by type name. The style of the corresponding format cell is then used.

    But if you really sure that you need to set this variable dynamically then Java API can be used to access the grid command and set this attribute in the code.