Purpose
ZCL_XTT_FILE_GRID creates an XLSX template from an existing ALV grid. Use it when a separate workbook template would merely duplicate the ALV columns, grouping, totals, and colors.
Template sources
For a designed report, choose the storage adapter that matches the template source:

ZCL_XTT_FILE_SMW0for templates stored in transaction SMW0.ZCL_XTT_FILE_OAORfor OAOR/BDS storage with versioning.ZCL_XTT_FILE_RAWfor templates already available asSTRINGorXSTRING, often withZCL_XTT_HTML.
Generate from ALV
For reports based on CL_SALV_TABLE or CL_GUI_ALV_GRID, ZCL_XTT_FILE_GRID builds the initial template and retains ALV grouping and subtotals.
The generated workbook uses modern formatting and supports richer XTT post-processing than the standard spreadsheet export.

Different colors for subtotals (line 20) and modern Calibri font

If subtotals are grouped

In the final report, the data will also be grouped

ALV colors
The adapter maps COL_POSITIVE to green, COL_NEGATIVE to red, and COL_TOTAL to yellow through conditional formatting.

Technically this feature is implemented by conditional formatting
If the report starts with CL_SALV_TABLE, use ZCL_EUI_CONV=>GET_GRID_FROM_SALV( ) to obtain the CL_GUI_ALV_GRID reference required by the ZCL_XTT_FILE_GRID constructor.