Skip to content

Breaks merged cells #3

@Rizado

Description

@Rizado

I open .ods file which contains 3 sheets and trying to add some values on first sheet.
Third sheet contains merged cells.
When I save file merged cells are broken and I have to merge them again.
I user this code:

currRow = 2 # table has header!

try:
    docsrc = oo.Calc(opendoc=srcfile)
    docsrc.set_sheet_index(0)
    (cols, rows) = docsrc.get_sheet_dimensions()
    docdst = oo.Calc(opendoc=out_file)
    docdst.set_sheet_index(0)
    for i in range(2, rows + 1):
        if type(docsrc.get_cell_value(1, i)) != type(None):
            docdst.set_cell_value(1, currRow, 'string', docsrc.get_cell_value(1, i)[1])
            currRow += 1
    docdst.save(out_file)
except Exception as e:
    print(e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions