Ask Your Question
1

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

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

Tass gravatar image

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 flag offensive 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

Comments

In what way (by what means) did you create your chemical formulae?
(Please read https://ask.libreoffice.org/en/questi....)

Lupp gravatar imageLupp ( 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.

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

2 Answers

Sort by » oldest newest most voted
1

answered 2018-05-08 11:53:04 +0200

Lupp gravatar image

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.

edit flag offensive delete link more

Comments

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.

Tass gravatar imageTass ( 2018-05-08 12:12:01 +0200 )edit
0

answered 2018-05-08 12:02:43 +0200

Jim K gravatar image

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.

edit flag offensive delete link more

Comments

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.

Tass gravatar imageTass ( 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.

Lupp gravatar imageLupp ( 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?

Jim K gravatar imageJim K ( 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.

Lupp gravatar imageLupp ( 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)

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

Question Tools

1 follower

Stats

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

Seen: 48 times

Last updated: May 08 '18