diference of using node vs data
diference of using node vs data
arcanisgk
Posts: 41Questions: 12Answers: 0
given a table cell contains the following:
Hello Word1,<br>Hello Word2
to get on browser view:
Hello Word1,
Hello Word2
when i try to use format for excel exportation:
format: {
body: function (data, row, column, node) {
data = $(node).clone('td');
data = data.text();
data = data.replace(/<br\s*\/?>/ig, "\r\n");
return data;
this not replace my br with line brake to get work for excel esport... when i see that .text()
result, i get Hello Word1,Hello Word2
whitout <br>
.
why node
or clone td
; not copy the <br>
to be replace in next interaction???
Answers
My understanding is
text()
only returns text not the tags. Instead you proably will need to usehtml()
. See this technote. This exmple, using your code, shows thatnode
returns the node as it is in HTML with thebr
tag.http://live.datatables.net/calemomi/1/edit
You may also need to add the wrap text attribute. See this thread for an example.
Kevin
the two questions are not related, they are different things... in this question I have already obtained the line break for excel but I cannot upload a test case, since the error is visible when the excel is opened and all cells with 2 or more lines with style 55; they apply a text wrap that allows the full text to be seen if I remove it or combine it with another style, excel stops respecting line breaks and even if they exist... I must go to each cell one by one, click on it as if I were going to edit the text remove the focus (no change made) from the cell so that it respects the line break again...
I don't actually understand the question I'm sorry to say. Do you mean the height of the row in Excel is not correct to be able to see the whole text?
Allan
yes allan and zorry the right post is here: https://datatables.net/forums/discussion/74504/problem-apply-multiple-style-to-table-cell-export-to-excel#latest