Export to Excel -- way to use different TH value in export.
Export to Excel -- way to use different TH value in export.
Is there a way to use different table header text in the exported version, vs. the screen version.
It would be nice to be able to do something like this, so that the screen could show a time duration in human-readable format but the Excel export just have the total # of minutes -- and the spreadsheet header reflect the Units:
<table>
<thead>
<tr>
<th data-sort="Duration (minutes)"> Duration (HH:mm) </th>
</tr>
</thead>
<tbody>
<tr>
<td data-sort="150"> 2:30 </td>
</tr>
</tbody>
</table>
specifying exportOptions.orthogonal = 'sort'
Is there a way to do this?
Answers
See if this thread helps to customize the header export.
Kevin
Yes, a custom formatting function for the header is probably the best way to do it.
However, if you need to based a calculation from the other rows in the table (your question makes it sound like you might was to sum the values?) then use
customizeData
frombuttons.exportData()
which lets you overwrite the values that have been read in.I can put an example of that together for you if you like. I'm just not clear on if you are doing a sum or not.
Allan
It looks like the example from the thread Kevin linked should help me. (I do not need to do a sum.)
I essentially just want the Screen vs Export column to be formatted differently: in a nice human-readable form for the screen -- vs. a straight number for the export. This is easy to do for the column <td> value itself, via the
orthogonal
option and using, for example,data-sort
on the <td> cell.Would it be possible to request that the
orthogonal
option also support using, for example,data-sort
for the <th> cells, as well? That would be an easy and consistent way to do it...?The orthogonal concept doesn't extend beyond the data in the table body at the moment. I'd need to have a think about how to introduce it beyond that, but you are right it might be sensible to do so. I need to have a think about what other areas it might be useful. It it is only export, then improving the formatting functions or perhaps introducing an orthogonal approach only there might be the way to do it.
Let me know how you get on with!
Allan
I was able to implement this in a generic way for us. (We have an extension to dataTables, so that we can set & provide features, etc. in common across all tables.)
Thanks for the starting help.
Very nice! Thanks for letting us know you've got it working as you need.
Allan