Search code examples
swtnattable

Copying Nattable cells and pasting in excel does not work properly


My nattable looks like the one below.

enter image description here

When I copy the cells and paste in excel the cells look distorted as below.

enter image description here

The line break is not captured properly in the process. The bit of code referred for copying is the same as that in the Nattable example enter image description here

Is this a bug and solved in the next versions or am I missing on something.


Solution

  • The solution as of now is as follows :-

    In Excel if the content that is sent to the Clipboard is present in double quotes and the \n is included in the double quotes Excel interprets this as a single cell content and adds the line break in the cell

    Alternatively since this is a table while copying content to the clipboard we can convert it to html tags appropriately and convert it to html format which excel reads and converts appropriately.

    Refer below image

    enter image description here

    However while copying between cells from Nattable to Nattable this is taken care of.