Excel Export force text format
Excel Export force text format
eddiefantastic
Posts: 7Questions: 3Answers: 0
in Buttons
I have a very similar issue to this...
https://datatables.net/forums/discussion/50970/excel-export-format-cells-as-text
...and the solution there does give the desired result, almost.
My problem is that I am also using colvis so I don't know which column letter(s) I need to apply the following to...
$("row c", sheet).attr( "s", "50" );
I would like to only apply that to columns where columnDef type = "string".
Any ideas?
Thanks.
This question has an accepted answers - jump to answer
Answers
There isn't an API method to get the column type unfortunately, so the best option is probably to apply a class to the columns that you have as strings -
columns.className
.Then in your
customize
function you can loop over the columns (columns().every()
) and check the class name of each (column().node()
to get the element and they use jQuery orclassList
to check the class name for the cell). If it matches, apply the50
style to the corresponding column.Allan
Thanks for the help. Not pretty but this seems to work...
The extra function. This will need adjusting if I ever have more than 26 possible columns...