[Python] LibreOffice UNO API: Column Page Breaks Not Resetting, Unlike Row Breaks

Discussão em 'Python' iniciado por Stack, Março 1, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using the LibreOffice UNO API with Python to programmatically apply row and column page breaks in a Calc spreadsheet. I've encountered a discrepancy in how row and column breaks are handled.

    When I apply new row breaks using rows.getByIndex(row_break_id).IsStartOfNewPage = True, existing row breaks are correctly reset or overwritten. However, when I apply column breaks using cols.getByIndex(col_break_id).IsStartOfNewPage = True, while the new breaks are applied, the initial column breaks in the document are not removed.

    I've attempted to reset the initial column breaks by iterating through the columns and setting IsStartOfNewPage = False:

    for i in range(min(cols.getCount(), 100)):
    if cols.getByIndex(i).IsStartOfNewPage:
    print("page break at:", i)
    cols.getByIndex(i).IsStartOfNewPage = False


    However, this code doesn't seem to have any effect. The IsStartOfNewPage property remains True for the initial column breaks, even after executing this loop.

    Here's the code I'm using to apply the row and column breaks:

    if row_break_id > 0:
    rows.getByIndex(row_break_id).IsStartOfNewPage = True

    if col_break_id > 0:
    cols.getByIndex(col_break_id).IsStartOfNewPage = True
    print("applying col break at:", col_break_id)


    My Questions:

    1. Why are column breaks behaving differently from row breaks in this context?
    2. How can I reliably reset or remove the initial column breaks using the UNO API?
    3. Are there any LibreOffice settings or document properties that might be interfering with the column break behavior?
    4. Is there any way to force libreoffice to recalculate the page breaks after setting the IsStartOfNewPage to False?
    5. Are there alternative methods to achieve the desired column break behavior using the UNO API or other approaches?

    Any insights or solutions would be greatly appreciated.

    Continue reading...

Compartilhe esta Página