Hushedar Merwan
Hushedar Merwan

Reputation: 42

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.

Upvotes: 0

Views: 232

Answers (2)

Hushedar Merwan
Hushedar Merwan

Reputation: 42

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.

Upvotes: 0

Dirk Fauth
Dirk Fauth

Reputation: 4231

I would not say that this is a bug in NatTable. Pasting a line break into Excel inside a cell is not that simple. You can search for this topic and see the real issue. When you copy content from NatTable, the content includes the line breaks of your cell data. The paste operation in Excel takes those line breaks and interpretes them as new row and not new line inside a cell.

You can of course implement and register a custom CopyDataCommandHandler that performs special operations to replace a line breaks in NatTable content with something that Excel handles as line breaks inside a cell.

Upvotes: 0

Related Questions