# no proper formated table import from calc to writer? [closed]

Hi,

I have a calc table with many chemical formulas which include sub- and superscript. Wanting to transfer this table into a writer document, the only way to preserve this formatting is pasting a calc table, which is an unsuitable option if you want a nicely formatted document at the end. All other non-picture options provided under paste special do not preserve the formatting.

Is there another way of importing such a table? It would be disappointing if such a simple operation was not possible.

Best regards.

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Tass close date 2018-05-10 10:10:53.864480

In what way (by what means) did you create your chemical formulae?

( 2018-05-08 08:53:28 +0200 )edit

They were created in calc using the sub- and superscript formatting. e.g. NH4+ with the 4 in subscript and the + in superscript.

( 2018-05-08 09:12:23 +0200 )edit

Sort by » oldest newest most voted

It's strange.
You can Copy/PasteSpecial a single formula of that kind from a spreadsheet (Calc) to a text document (Writer) using Paste Special... in RTF mode. (This changes the relative size of sub/super, however, a bit.) If you try to import formulae from a CellRange this way, RTF will create a table and ignore Sub/Super.
RTF is an old mess, I can't help. I would suppose LibreOffice tries to reproduce a behaviour originally introduced by MS. And everything going through the clipboard is afflicted by the properties of that tool and the formats it supports (OS dependent).

Anyway "formulae" based on character styles are very limited. You cannot have a superscript (high index) above a subscript (low index) e.g. as is needed for the common nuclide notation or for a chemical application where charge signs should display above counting indices or the like.

To avoid problems of the kind you may try the 'Math' component of LibreOffice which can be used to create formulae as OLE objects in Writer and in Calc as well. No difference in appearance then.

more

Thanks, at least I know now that I am not too dumb to find the proper way to do it but that amazingly there is no copying function. You can only transfer content but not copy! In 2018! Amazing.

( 2018-05-08 12:12:01 +0200 )edit

Create a new table in Writer (Table -> Insert Table) with the appropriate number of rows and columns.

Then copy and paste special (Formatted text [RTF]) for each individual cell.

If the table is very large, then it may be worth writing a macro to automate the copying and pasting.

more

Thanks, but in that case I can also rewrite it. A macro is not worth it as I plan to do this only once. Amazing that there is no straightforward way of copying from a to b. If it only transfers the content it does actually not copy.

( 2018-05-08 12:10:01 +0200 )edit

Quoting @Jim K: "If the table is very large, then it may be worth writing a macro to automate the copying and pasting."
Do you know how to do this kind of Copy/Paste without losing formats by custom code?
I tried but did not succeed with an insertion on the paragraph level. So far I had to insert on the TextPortion level, and for preserving the format to pass every sigle property as an element of a PropertyValues array.
That's too complicated.

( 2018-05-08 16:52:47 +0200 )edit

My idea was a dispatcher call to .uno:PasteSpecial using the RTF setting, at the paragraph level of each cell. However, I did not verify that it works. Is that what you tried?

( 2018-05-09 02:51:14 +0200 )edit

I tried that the manual way and observed "(This changes the relative size of sub/super, however, a bit.)" as I reported in my answer.
To Copy/Paste formatted Text correctly from Calc to Writer by user code seems to be a ticklish task. This may be related to different implementations of the Text service in Calc as compared with Writer. However, I don't understand Text and TextCursors, TextRanges... on a level required to clear this eventually.

( 2018-05-09 11:53:54 +0200 )edit

Strange enough: Copy/Paste (without "Special"!) works much better in the reverse direction for tables which are mapped to CellRanges.
"The universe is made to be a stage for surprises. " (Lupp)

( 2018-05-09 12:00:11 +0200 )edit

## Stats

Asked: 2018-05-08 07:13:09 +0200

Seen: 48 times

Last updated: May 08 '18