{tableexport:selector}

Description

Adds an "Export to XLSX" button to every HTML table on the page that matches the CSS selector. It loads the required JavaScript libraries (the TableExport library plus its dependencies) and registers an init script - it prints nothing into the page itself, so its output is always empty. The button lets a visitor download the table as an Excel .xlsx file. Two requirements: the table must carry a class or id that the selector targets, and the Site module template must use generate:HEAD and generate:FOOT so the libraries get emitted. The underlying JavaScript library may be swapped for an equivalent one in the future, but the command stays functional. Class: AA_Stringexpand_Tableexport.

Parameters

selector required default (none)

A CSS selector picking which table(s) get an Export to XLSX button. Use a class like .xlsexportable or an id like #report. The command targets every element matching it on the page. With no selector the command does nothing.

Examples

test[{tableexport:.xlsexportable}]
Expected[]
Actual[]
The typical call: attach an Export to XLSX button to every table with class xlsexportable. The command prints nothing, so the brackets stay empty - its work is loading the export library and registering the button in the page footer.
test[{tableexport:#report}]
Expected[]
Actual[]
An id selector targets one specific table (the element with id report). Output is still empty; the button is added to that table only.
test[{tableexport:}]
Expected[]
Actual[]
With no selector the command is a no-op: it loads no library and adds no button. The output is empty, just as when a selector is given - so an accidental empty call is harmless.
virtual{tableexport:.xlsexportable} <table class="xlsexportable"> <tr><th>Name</th><th>Votes</th></tr> <tr><td>Alpha</td><td>12</td></tr> </table>
Expected(the table renders with an Export to XLSX button below it; the tableexport call itself adds no visible text)
Actual
NameVotes
Alpha12
The real-world pattern: call tableexport once, then output a table whose class matches the selector. Put the tableexport call in a view before field and the table in its odd or after field. The Site module template must use generate:HEAD and generate:FOOT so the export library loads. Marked illustrative because the visible result is the rendered table plus a download button, not a text value, and the button only appears once the libraries are present.