Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Try with:

def test_sort():
    from com.sun.star.table import TableSortField
    from com.sun.star.table.TableSortFieldType import AUTOMATIC

    doc = XSCRIPTCONTEXT.getDocument()
    sheet = doc.getSheets().getByIndex(0)
    rango = sheet.getCellRangeByName('A1:C11')

    field = TableSortField()
    field.Field = 1
    field.IsAscending = True
    field.FieldType = AUTOMATIC

    sd = rango.createSortDescriptor()
    sd[1].Name = 'ContainsHeader'
    sd[1].Value = True
    sd[3].Name = 'SortFields'
    sd[3].Value = uno.Any('[]com.sun.star.table.TableSortField', (field,))

    uno.invoke(rango, 'sort', (sd,))
    return

Best regards