Type Template Report
Excel Download template Download report
Generate this example Choose a template and create a fresh report with the demo service.

xtt->merge( iv_block_name = 'R' is_block =

JSON
{"TITLE":"Title","T":[{"GROUP":"GRP A","CAPTION":"<Caption 1 />","DATE":"2020-10-21","SUM1":5971.44,"SUM2":5021.46},{"GROUP":"GRP C","CAPTION":"<Caption 2 />","DATE":"2020-10-19","SUM1":2276.75,"SUM2":7717.2},{"GROUP":"GRP B","CAPTION":"<Caption 3 />","DATE":"2020-10-20","SUM1":3031.38,"SUM2":445.22},{"GROUP":"GRP A","CAPTION":"<Caption 4 />","DATE":"2020-10-21","SUM1":9476.79,"SUM2":3683.27},{"GROUP":"GRP A","CAPTION":"<Caption 5 />","DATE":"2020-10-21","SUM1":4604.0,"SUM2":5525.85},{"GROUP":"GRP C","CAPTION":"<Caption 6 />","DATE":"2020-10-19","SUM1":2159.71,"SUM2":2260.94},{"GROUP":"GRP B","CAPTION":"<Caption 7 />","DATE":"2020-10-20","SUM1":2490.3,"SUM2":6388.81},{"GROUP":"GRP A","CAPTION":"<Caption 8 />","DATE":"2020-10-21","SUM1":5476.81,"SUM2":406.18},{"GROUP":"GRP D","CAPTION":"<Caption 9 />","DATE":"2020-10-18","SUM1":689.66,"SUM2":518.6},{"GROUP":"GRP C","CAPTION":"<Caption 10 />","DATE":"2020-10-19","SUM1":5451.87,"SUM2":4061.85},{"GROUP":"GRP D","CAPTION":"<Caption 11 />","DATE":"2020-10-18","SUM1":4573.55,"SUM2":5436.0},{"GROUP":"GRP C","CAPTION":"<Caption 12 />","DATE":"2020-10-19","SUM1":1196.35,"SUM2":522.46},{"GROUP":"GRP C","CAPTION":"<Caption 13 />","DATE":"2020-10-19","SUM1":7686.95,"SUM2":2727.98},{"GROUP":"GRP D","CAPTION":"<Caption 14 />","DATE":"2020-10-18","SUM1":978.18,"SUM2":295.55},{"GROUP":"GRP D","CAPTION":"<Caption 15 />","DATE":"2020-10-18","SUM1":71.12,"SUM2":8878.56}],"DATE":"2020-10-21","TIME":"12:12:12","DATETIME":"20201021121212"}

).


xtt->merge( iv_block_name = 'A' is_block =

JSON
[{"INFO":"String 1 "},{"INFO":"String 2 "},{"INFO":"String 3 "}]

).


Generate demo 021

Different formulas

Request preview

Purpose

Demo ZCL_XTT_DEMO_021 shows how formulas survive row and column expansion. Define formulas in Excel, where they remain visible and testable; generating formula strings in ABAP is fragile and differs between XLSX absolute references and Excel XML relative references.

Formula-copying model

XTT creates new rows and cells by copying the template range. Formulas travel with values, borders, styles, and other cell properties.

To prevent the formulas from “shifting” during copying cells, you can use several methods:

Relative references in XLSX

For references relative to the current formula cell, use OFFSET() with INDIRECT(), or use R1C1 notation through INDIRECT().

To sum the preceding three cells, move three columns left and return a three-column range.

image

The offset can also be specified directly in INDIRECT(“RC[-3]”, 0), in such formulas it can also be useful:

  • =ROW() &
  • =COLUMN() functions

which, without passing arguments, return the current row and column

Runtime row substitution

As a simpler alternative, XTT supports a template-specific $ rule:

When the current template row number is prefixed with $, XTT replaces it with the generated row number at runtime.

image

The final report will be like this

image

For ;direction=column, the equivalent substitution applies to column references such as $E.

Shared formulas

Current XTT versions preserve repeated shared formulas while converting between absolute and relative references. This avoids the disappearing-formula problem seen in older releases.

image


Named ranges

Named ranges are updated during generation:

  • A normal named range is expanded once to cover the generated data.

image

  • If the name ends in _, XTT repeats the range and substitutes the resulting range list into the formula.

image

Totals, arrays, and conditional formatting

You do not need named ranges or an XTT tree merely to total a flat Excel table. Standard Excel table formulas are often sufficient.

Use Excel’s native table features when the calculation is specific to XLSX output.

image

Array formulas are also supported

image

For calculations that must also work in Word or PDF, use XTT aggregation functions: ;func=SUM, AVG, COUNT, or FIRST.

For conditional-formatting formulas, define the applicable range as whole columns when possible. This gives XTT room to expand the data without leaving generated cells outside the rule.

image