Export Excel/PDF : Add legend multi line

Export Excel/PDF : Add legend multi line

xavstargatexavstargate Posts: 1Questions: 1Answers: 0

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 !

Answers

  • kthorngrenkthorngren Posts: 1,403Questions: 17Answers: 283

    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:

    1. Use the CONCATENATE and CHAR functions to build the string with newlines, example: CONCATENATE("Line 1", CHAR(13), "Line 2")
    2. Change the cell type to formula
    3. Change the formatting of the cell to include word wrap

    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

  • allanallan Posts: 42,648Questions: 1Answers: 5,492 Site admin

    You can use style 55 which is built into the XSLX file generated by Buttons to cause \n to display as new lines - see the excelHtml5 documentation and also this example for how to change the style of a cell.

    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.

    Yup :).

    Allan

  • allanallan Posts: 42,648Questions: 1Answers: 5,492 Site admin

    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

Sign In or Register to comment.