Need help with text formating in cell LibreOffice Calc

Hi, i have about 6k cell with data like this: (the left cell on image) and i need to change them all to look like right cell in the image.
The point is, i never worked with “condition” (or if there is any other method i can do that) so i need help or any information how to start.

In worst case scenario i wiil be spending couple days to do this manually.
Hope there is better way :/.

example

Thanks for any help.

You can not format text parts differenly in a cell

  • by Cell Style
  • nor by Conditional Format feature.

You can do it manually only (one by one).

I suggest you to use standalone cell for the number part of the whole content. Then you can apply a well adjusted cell for the cell containing the number, and an another style for the cell containing a string part.
And then you can apply the Conditional Format property - if you really need it.

2 Likes

With a macro?

You may take it as a joke, but I am serious:
You may have a feeble for that appearance with muiltiline cells, and may want it, but you surely do not need it.
“Cells with data” should mean cells with data.
Cells formatted for prettyprint or for impressing somebody aren’t data.
Some experienced users will claim generally that spreadsheets for keeping and maintaining data are a misuse of the software, and that everything of the kind should be done using databases. I’m not that strict about it,
My dogma is this:
Every single sheets for data maintenance is for data maintenance and for nothing else! Main criterion: Export of the sheet to a csv representation must be possible without loss. For the reimport this applies accordingly
Sheets for printing or for presenting in specialized formats can never be used at the same time for data keeping.

You want to tell people how to use your tool. :face_with_raised_eyebrow:

Who’s “you” in this post?

And what is “this post”? :slight_smile:
You can see who is “you” (Craix), by editing the comment.

  • image

Sometimes we forget to quote, and that can lead to confusion.

6k wow, yes, you need a macro. The next code does the job.

import uno

def main():

    doc = XSCRIPTCONTEXT.getDocument()
    selection = doc.CurrentController.Selection
    sheet = selection.Spreadsheet
    ra = selection.RangeAddress

    for row in range(ra.StartRow, ra.EndRow + 1):
        for col in range(ra.StartColumn, ra.EndColumn +1):
            cell = sheet[row, col]
            text = cell.Text
            for t in text:
                c = text.createTextCursorByRange(t)
                c.CharHeight = 20
                c.CharWeight = 200
                break

    return

2 Likes

better:

def main():
    doc = XSCRIPTCONTEXT.getDocument()
    selection = doc.CurrentSelection
    multi = selection.queryContentCells(4)
    for cell in multi.Cells:
        text = cell.Text
        line = next(iter(text))
        tc = text.createTextCursorByRange(line)
        tc.CharHeight = 20
        tc.CharWeight = 150        
    selection.Rows.OptimalHeight = True
1 Like