I already have the code for exporting a html table to excel, but how can I hide the table and still access it with javascript?
<div id="dataExportDiv" style="display:none">
<table>
...table data here...
</table>
</div>
But the resulting excel document doesn’t have any data. I’ve tried exporting without hiding the table and it works, so I know the export javascript is valid.
You could display the table off screen (out of the viewport):
Beware that it’ll still display if CSS are desactivated (obviously) and will be read by screen readers.
If you’re displaying a chart, this table will be a good text alternative to them (with proper
thandscope="col|row") otherwise they’ll find it a PITA if it’s 3km long.In the latter case, you can hide the table from most recent screen readers with the attribute
aria-hidden="true"ontableelement and provide a skip link just before the table for older screen readers.