Skip to content

List index out of bounds when accessing cells of a WriteTableRow #707

Description

@isolk5

I think I just found a bug

Look at this code

def generate_order(pathname, order):
    from ooodev.loader.lo import Lo
    from ooodev.write.write_doc import WriteDoc

    loader = Lo.load_office(Lo.ConnectSocket(
        headless=True,
        ))
    doc = WriteDoc.open_doc(fnm=pathname, loader=loader)
    
    #Inizio a rimpiazzare tutte le stringhe con i dati
    try:
        replace(doc, "&FORNITORE", order.supplier.legal_name)
        replace(doc, "&INDIRIZZO", order.supplier.get_legal_address().address)
        replace(doc, "&LOCALITA", order.supplier.get_legal_address().city_address)
        replace(doc, "&PROTOCOLLO", order.protocol)
        replace(doc, "&DATAORDINE", utilities.format_date(order.order_date))
        #Valorizzo tabella dettagli
        table = doc.tables.get_by_index(2)
        for detail in order.to_details.all():
            new_row = table.rows.append_row() 
            new_row["A1"].value = detail.material.description 
            new_row["B1"].value = 'PROVA'

It works well, but if I change cell indexing mode to integers

            new_row[0].value = detail.material.description 
            new_row[1].value = 'PROVA'

I get a list index out of bound exception on the [1] indexed row
The table in my document has 5 colums

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