Table AutoFormat UNO command

Hi there.

Is there any way to interact with Table AutoFormat using UNO?

Or is there any way of saving a TableStyle to a document?

Thanks

Always mention OS and LibreOffice Version.
(Table Styles were implemented with V 5.3.)

  1. There is no usable .uno: command supporting the needed arguments.
  2. A Table Style is a complicated thing.
  3. Table Styles created by the user are stored to the document file anyway.
  4. Strangely the API name of the relevant property of a TextTable having assigned a style is TableTemplateName. (“Don’t miss an opportunity to mess up terms!”)
  5. If you want to have an editor for TextTable styles you may need to write one.
  6. The code contained in the attached file should demonstrate a simple use case, and help you to start with the project.

disask95532rstyleTableWithCustomStyle.odt (13.2 KB)

1 Like

Thank you for your reply, that’s interesting. I was confused because in python, if I do:

    families = document.getStyleFamilies().getElementNames()
    for family in families:
        styles = document.getStyleFamilies().getByName(family).getElementNames()
        for style in styles:
            print(family + ": " + style)

I can see that there is the table styles listed there - but if I open the document on a new system, the table styles are gone.

I have since seen here that the table styles are stored in the LibreOffice user profile!

So, for my use case, I will have my users retrieve the autotbl.fmt file from their config folder, if they want to customise the look of the tables.

Thanks again for the help.

I didn’t research into the user profile insofar, but the reported observation can’t be correct and complete enough. My example loaded with an older PortableApps version of LibO where the used custom Table style surely isn’t “profiled” shows it correctly, and the given code does as expected.
Well, Python users may dislike Basic, but my code isn’t poisonous, and the bridge from onboard Basic to the API is short, wide, and simple to use… Simply run it in the Basic IDE step by step to learn what I wanted to show.