Excel / Copy buttons - Keep formatting in some cells
Excel / Copy buttons - Keep formatting in some cells
Hi,
I'm using the Excel / Copy buttons, which are working fine for most situations.
However I have a situation where a particular column contains html data, which is then rendered, please see these simple cells:
If I export that table, the Excel (or copy) button will create a cell containing:
line1line2line3
Is ok that only a cell is created, but how can I tell the button to insert in the cell the new line break character?
This question has an accepted answers - jump to answer
Answers
This thread might help you out.
https://datatables.net/forums/discussion/comment/167672/
Warning: Customizing the client side Excel export can be very cumbersome and complex! Data tables does have some styles built in but you may end up having to create your own, for example
The export gets it's data from the
buttons.exportData()
method. Which by default will strip HTML and new lines.What you want to do is set the
stripNewlines
option tofalse
for theexportOptions
object in your export button:Allan
I added, in my html data, the character that Excel uses to add a new line in a cell, i.e.
char(10)
.But there is still a problem: the user creates the Excel using the buttons and, after opening it, he needs to press the "wrap text" button in the column containing the wrapped data:
Without doing so, the data is not wrapped.
Is there a way to create the Excel and "forcing" wrapping data?
Please see this similar problem and solution (non related to DataTables):
Thanks!
This thread discusses one option.
Kevin
Thanks Kevin!
This will do the trick (where "F" is the desired column):
$('row c[r^="F"]', sheet).attr('s', '55');