Since the download to excel button takes filters into account, the quickest solution would be adding a button above or below the grid which only displays selected rows.
a!localVariables(
local!selectedRows: {},
local!filterSelectedRows: false,
{
a!gridField(
label: "Read-only Grid",
labelPosition: "ABOVE",
data: a!recordData(
'recordType!{SYSTEM_RECORD_TYPE_USER}User',
{
a!queryFilter(
"myField",
"in",
local!selectedRows["RecordType.fields.id"],
local!filterSelectedRows
)
}
),
columns: {},
selectable: true,
selectionValue: local!selectedRows,
selectionSaveInto: {
local!selectedRows
},
validations: {}
),
a!linkfield(
links: {
a!dynamicLink(
label: if(
local!filterSelectedRows,
"Unfilter selected rows",
"Filter selected rows"
),
value: not(local!filterSelectedRows),
saveInto: local!filterSelectedRows
)
}
)
}
)