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)
Note:
i have tested this on a simple table with 17 columns and 3 rows created on a blank sheet.i can assure that its not a document issue as this issue persist on all the document i tested.
I am using windows 11 and LibreOffice 25.2.1
My Questions:
- Why are column breaks behaving differently from row breaks in this context?
- How can I reliably reset or remove the initial column breaks using the UNO API?
- Are there any LibreOffice settings or document properties that might be interfering with the column break behavior?
- Is there any way to force libreoffice to recalculate the page breaks after setting the
IsStartOfNewPagetoFalse? - 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.
Starting LibreOffice in Socket Listening Mode
Connecting to LibreOffice and Accessing the Sheet
Attempting to Remove Existing Column Page Breaks
Verifying If Column Breaks Were Removed
Observation: The Automatic column page breaks remain