Export Excel/PDF : Add legend multi line
Export Excel/PDF : Add legend multi line

How make this ?
Use messageBottom/messageTop ?
Doesn't work in Excel for multi line, "\n" doesn't work properly, but it's work in PDF
Thanks !
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Excel doesn't use
\n
for newlines. Unfortunately, due to the format of the XML file Excel and other spreadsheets use, it is not a simple task to insert newlines within the text. To use newlines with the Datatables Excel export the following steps are needed for each cell:CONCATENATE("Line 1", CHAR(13), "Line 2")
This thread explains how to do this for the data portion that is exported:
https://datatables.net/forums/discussion/41778
I'm not sure if the messageTop and messageBottom options support applying the styles from the style sheet in the same way the data area does.
Kevin
You can use style 55 which is built into the XSLX file generated by Buttons to cause
\n
to display as new lines - see theexcelHtml5
documentation and also this example for how to change the style of a cell.Yup
.
Allan
Oh - One other thing. You have to disable the stripping of new line characters in the export options for the button - otherwise they will just be removed!
Allan
Thanks
How do you "disable the stripping of new line characters"? Thank you!
See
stripNewlines
option here ,Colin
Ok, I'm now running
stripNewlines: false
in my excel export, but there are still no linebreaks in my messageTop. It seems like "\n" is still getting stripped. Any workarounds?We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin