Bug 152984 - Support cell formatting in HTML pasted/opened/linked in Calc (e.g. coming from Google Sheets)
Summary: Support cell formatting in HTML pasted/opened/linked in Calc (e.g. coming fro...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:html
: 160500 (view as bug list)
Depends on:
Blocks: Paste
  Show dependency treegraph
 
Reported: 2023-01-12 00:39 UTC by AvidSeeker
Modified: 2024-04-04 13:46 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Original Google sheet (left) and result in LO 7.6 alpha0+ (305.90 KB, image/png)
2023-01-13 08:59 UTC, Stéphane Guillou (stragu)
Details
Original Google sheet (left) and result in MS Excel (436.82 KB, image/png)
2023-01-13 09:09 UTC, Stéphane Guillou (stragu)
Details
Clipboard's HTML of the Google Sheet (125.55 KB, text/html)
2023-01-14 09:32 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description AvidSeeker 2023-01-12 00:39:46 UTC
Related forum post: https://ask.libreoffice.org/t/support-formatted-paste-from-google-sheets/86358/4

Reproduce:

1. Have a styled sheet in Google 
2. Select all, 
3. Paste in Libreoffice Calc

One expects to have the (1) style and (2) merged cells all imported to Libreoffice just by pasting.

Actual result is that it’s no different that “paste unformatted”, and cells are left unmerged.

However, the opposite works. Try this: Copy a styled spreadsheet in Libreoffice and paste it in Google Sheets. It will import all colors and merged cells.
Comment 1 Stéphane Guillou (stragu) 2023-01-12 15:24:57 UTC
Hi AvidSeeker

Can you please provide an example public Google Sheet document, and list more precisely which attributes in which cells are not copied across?
So we can keep the report focused and test more easily.

Also please try a more recent version of LibreOffice. Version 7.4.4 was just released.

Thank you!
Comment 2 AvidSeeker 2023-01-13 05:42:56 UTC
[Google Sheets template gallery](https://docs.google.com/spreadsheets/u/0/?ftv=1) can be used as test cases.


Here are examples from "monthly budget" templates:

Google Sheet screenshot: https://i.imgur.com/OepYKBa.png

Libreoffice Calc screenshot: https://i.imgur.com/wss0uhA.png

As I said, attributes are style (bold, italic, color, highlight, border, etc.) and merged cells. 

Relevant discussion: https://ask.libreoffice.org/t/support-formatted-paste-from-google-sheets/86358/10?u=avidseeker
Comment 3 Stéphane Guillou (stragu) 2023-01-13 08:58:09 UTC
I can reproduce in LO 7.6 for the formatting, but not the merged cells (can you be more specific about which merged cells are lost?)

Steps:
1. Open this public Google Sheets template: https://docs.google.com/spreadsheets/d/1R-JMH4PqpbDmTbZqq6qKtMU69P-v1xa94pvD2v5spnc/edit
2. Ctrl + A, Ctrl + C to copy all cells
3. In LO Calc, paste

Results:
No cell formatting at all makes it across, as it is plain text that is pasted.
Formulas and sparklines are also lost.

More info:
Pasting into Gnumeric 1.12.46 does the same: only plain text. (Note that it _looks_ like it keeps the formatting of negative numbers in F26 and F30, but that's just Gnumeric's default negative number formatting.)

Two workarounds:
1) save the Google Sheet as ODS or XLSX, open in LO to copy from there. Main remaining issue would be sparklines (I haven't checked the formulas' validity).
2) paste into Writer, then from Writer into Calc. From: https://ask.libreoffice.org/t/support-formatted-paste-from-google-sheets/86358/8

Tested with:

Firefox 108.0.2 (64-bit) and Chromium 109.0.5414.74 (Official Build) snap (64-bit)

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 197e5f81213d14fdcbff40edf73385ecd4cd9815
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Same in:

Version: 6.1.0.3
Build ID: efb621ed25068d70781dc026f7e9c5187a4decd1
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk2; 
Locale: en-AU (en_AU.UTF-8); Calc: group threaded
Comment 4 Stéphane Guillou (stragu) 2023-01-13 08:59:15 UTC
Created attachment 184629 [details]
Original Google sheet (left) and result in LO 7.6 alpha0+
Comment 5 Stéphane Guillou (stragu) 2023-01-13 09:09:57 UTC
Created attachment 184631 [details]
Original Google sheet (left) and result in MS Excel

Result when pasted into Microsoft® Excel® for Microsoft 365 MSO (Version 2212 Build 16.0.15928.20196) 64-bit
Comment 6 Mike Kaganski 2023-01-14 08:59:46 UTC
There are only HTML and plain text formats in the clipboard after copy from GSheets in Chrome on Windows (I assume that two Google products would give the best possible result, and other combinations, e.g. FF, don't need own testing). Namely, the available formats are "HTML Format", "CF_UNICODETEXT", "CF_LOCALE", "CF_TEXT", and "CF_OEMTEXT".

All formats lack any formulas; so paste would only give values - e.g., the cell D17 "START BALANCE" is "=if(isblank(L8),0,L8)" in GSheets, but is simply "£1,000" in both Calc and Excel. This is the GSheets copy-to-clipboard limitation, and is NOTOURBUG.

Pasting to Excel preserves cell formatting, that uses CSS. Calc simply doesn't import any CSS, so this is an HTML import filter deficiency, not related to GSheets.
Comment 7 Mike Kaganski 2023-01-14 09:32:29 UTC
Created attachment 184657 [details]
Clipboard's HTML of the Google Sheet

(In reply to Mike Kaganski from comment #6)
> All formats lack any formulas

Ignore me.
The actual clipboard HTML (in attachment) does contain some Google-specific tags, which contain the cell number formats and formulas.

So supporting these (which is orthogonal to CSS) is a valid enhancement request. It could be re-worded as "improve importing the attached HTML using HTML Document (Calc) filter".
Comment 8 Stéphane Guillou (stragu) 2023-01-16 12:46:44 UTC
OK, let's clarify the summary then, thanks Mike.

Same happens if using the "Sheet > External links..." tool.

Note that the default paste option is the same as using the HTML option in Paste Special (or toolbar paste dropdown). I think it is sensible to expect this HTML option to have more formatting taken across (more than just a different font + the merged cells). Given how much better it works in MSO, and because it is about copying from an alternative spreadsheet application, I see this as a valid enhancement request for improved interoperability.

Situation was the same in OOo 3.3, so inherited:

OpenOffice.org 3.3.0
OOO330m20 (Build:9567)
Comment 9 m_a_riosv 2024-04-03 11:08:46 UTC
*** Bug 160500 has been marked as a duplicate of this bug. ***
Comment 10 Eric 2024-04-04 13:46:16 UTC
External links fail to copy over colors correctly in version 24.2.1.2
Is there a projected timeline for this to be worked on?