Bug 161223 - basic HTML cell render
Summary: basic HTML cell render
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsUXEval
Depends on:
Blocks: Cell-Formula
  Show dependency treegraph
 
Reported: 2024-05-23 06:40 UTC by David
Modified: 2024-06-06 06:48 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David 2024-05-23 06:40:35 UTC
Hi, I would like to suggest basic HTML render of cells on the spreadsheet, so format can be created based on basic formulas like if(something, "<b>", ""), similar to the way it works on the Qt framework widgets. Not the full set of HTML code is required, something basic like text format could add quite a functionallity and a step forward compared to competitor spreadsheet software. Best regards
Comment 1 Regina Henschel 2024-05-23 10:03:47 UTC
The request is not clear to me. Do you want to create the cell text by a formula? If yes, do you request an enhancement to the formula language to include formatting on parts of the text?
Comment 2 David 2024-05-23 19:35:58 UTC
My proposal is that the final render of the cell content could be based on a partial subset of html, focusing on format tags, this way on the final rendering phase if it contains tags they are used for format. It is quite similar to the way Qt widgets work. For a calc cell some examples:
- plain text -> no format at all
- after formula evaluation the result is plain text -> no format at all
- cell text has html tags -> apply them to the final render
- after formula evaluation the final text has html tags -> apply them to the final render

  I would stick to the basic format tags, like bold, italic, underline, etc, it does not make sense to implemente a table into a cell.

  I think this feature could improve a lot conditional format and become an advantage compared to competitors spreadsheet software.

BR
Comment 3 QA Administrators 2024-05-24 03:17:43 UTC Comment hidden (obsolete)
Comment 4 Heiko Tietze 2024-05-24 09:12:49 UTC
(In reply to David from comment #2)
>   I would stick to the basic format tags, like bold, italic, underline, etc,...
Enable Tools > AutoCorrect Options... > Options > Automatic *bold*, /italic/... to get this simple markup.
Comment 5 Regina Henschel 2024-05-24 10:52:26 UTC
(In reply to Heiko Tietze from comment #4)
> (In reply to David from comment #2)
> >   I would stick to the basic format tags, like bold, italic, underline, etc,...
> Enable Tools > AutoCorrect Options... > Options > Automatic *bold*,
> /italic/... to get this simple markup.

That solution does only work for text directly entered into the cell. When entering text directly into the cell, then all ways of direct character formatting is available. Request for character styles is in bug 108220.

The problem is, that it is not possible to style a part of text result of a function. You can only style the entire result string using the STYLE() function or using conditional formatting.

I can imagine a special text function that allows to style part of a text result. It need not be that it detects HTML markup, markdown would be possible as well. I personally would prefer not to use markup detection, but would prefer to first solve bug 108220 and then add a text function that applies a named character style to a portion of text.
Comment 6 Heiko Tietze 2024-05-24 12:03:09 UTC
David, please clarify your goal. Style text via function or have (limited) markup capabilities as done per autocorrection.
Comment 7 David 2024-05-24 17:03:10 UTC
  I will try to explain the use case we foresee for the proposed functionality. We are a medium size structural engineering office, many time we have to prepare complex structural reports based on results exported out of FE software in form of spreadsheets. For the automation of the creation of documents, we have spreadsheets we use as templates with the verification formulas of regulations like for example Eurocodes.
  Now we have one cell for the main check with an outcome like "Ok" "NOK" and conditional format, followed with an explanation and documental references on next an previous cells, text format is terrible for a formal pdf exportation.

  Think of a text similar to: "as expresed on clause EN 1993 4.2.1 for class 1 cross-section, buckling check <b>fails</b> due to <b>excesive slenderness</b> see equation 4.2.1b"

  This would be a very basic example that would be expressed into something like:
=if(CrossSectionClass=1,"as expresed on clause 4.2.1 EN 1990 for class 1 cross-section, buckling check "&if(checkingHere,"is ok","<b>fails</b> due to <b>"&causeOfFailureHere&"</b> see equation 4.2.1b"))
  This is the basic functionality.

  Medium functionality, if we want to go for the full package, would be a bit more complex font formating like: <span style="text-decoration: overline">λ</span> so we could write formulas on the conditions with mathematical required characters.

  And the "let's-make-a-magical-wish" functionality would include <img src="data:image/png;base64, ...> so you could even put different figures based on the conditions or in the middle of text explanations.

  As I said from the beginning simple text format html tags would be very useful for complex format conditions or conditional format in middle paragraphs. I think in html tags as they are near universal, but of course other format marks would be also useful.
  Medium functionality and "let's-go-crazy" functionality I know are just dreams :-)

Hope it clarifies the request.

BR
Comment 8 QA Administrators 2024-05-25 03:28:36 UTC Comment hidden (obsolete)
Comment 9 Heiko Tietze 2024-05-27 10:53:02 UTC
Would it be sufficient to evaluate the autocorrection in formulas? Like =IF(A1=1;"lorem *ipsum* dolor";"lorem ipsum _dolor_"). I'm thinking of these [M]/[T] options in Writer, see https://help.libreoffice.org/24.2/en-US/text/shared/01/06040100.html

Besides, you probably know the function HYPERLINK(). And TEXT() has a format option, though only for numbers.
Comment 10 David 2024-05-27 16:00:53 UTC
  Hi, 
  autocorrection in formulas would be better than nothing of course.
  I would say none of my coworkers know the autocorrection */- syntax but all of them know html tags. Also this option would not include colors/background, so it would improve conditional format... just a bit.
Comment 11 Eike Rathke 2024-05-30 14:51:22 UTC
This should by no means go into the formula expression engine, a spreadsheet function would be a wrong approach to render things.

Instead, a cell attribute could indicate that the cell content or formula result is to be rendered taking HTML (or whatever) elements into account.

Bear in mind that would add _yet another_ formatting layer somewhere in between or on top of

conditional formatting
hard cell attribution
cell styles

and possibly upcoming table styles that would go between cell styles and hard cell attribution.
Comment 12 David 2024-05-31 06:14:45 UTC
One approach could be function, kind of htmlrender()
Comment 13 Eike Rathke 2024-05-31 10:51:20 UTC
No, it could not. For one, expression calculation happens independent of rendering; second, expression calculation _never_ renders anything; third, such function would only get in the way when other implementations were trying to read the document and encountered the unsupported function, effectively invalidating interoperability. An unsupported cell attribute can simply be ignored.
Comment 14 Heiko Tietze 2024-06-06 06:48:09 UTC
We discussed the topic in the design meeting.

Given the implementation is quite difficult, the workflow likely cumbersome, and the use case somewhat niche, we suggest to realize the task per macro. There are plenty of guides available, for instance https://documentation.libreoffice.org/en/english-documentation/macro/. We also have a supporting group on Telegram or per mailing list.