How can I make standard filter copy info to a new sheet?


Hello I am trying to make LibreOffice grab data from the "main sheet’s column B and copy that info to it’s corresponding sheet. such as (if p5 is found in column B place it in sheet p5). alternatively i am okay with it being exported to a new file if possible. is there a way to do this? thank you for reading!

Hallo

def filter_B_to_sheetname(*_):
    doc = XSCRIPTCONTEXT.getDocument()
    sheets = doc.Sheets
    main = sheets["Main"]
    cursor = main.createCursor()
    cursor.gotoStartOfUsedArea(False)
    cursor.gotoEndOfUsedArea(True)
    source = cursor.DataArray
    for sheet in sheets[1:]:
        out = [row for row in source if row[1]==sheet.Name] # index 1 →Column B
        sheet[ 0:len(out), 0:len(out[0]) ].DataArray = out

Of course its python…may be you need apso.oxt to organize python

def create_and_filter_to_sheet(*_):
    doc = XSCRIPTCONTEXT.getDocument()
    sheets = doc.Sheets
    main = sheets.Tabelle1
    cursor = main.createCursor()
    cursor.gotoStartOfUsedArea(False)
    cursor.gotoEndOfUsedArea(True)
    source = cursor.DataArray
    criteria = set(row[1] for row in source) - {main.Name}
    for name in criteria:
        try: 
            sheets.insertNewByName(name, sheets.Count)
        except: 
            pass    
        out = [row for row in source if row[1] == name]
        sheets[name][0:len(out), 0:len(out[0])].DataArray = out