Tema: Re: Dar vienas Excel klausimas
Autorius: Grzegorz Brzęczyszczykiewicz
Data: 2021-02-11 23:15:40
def zyzai_calc():
    import uno
    from com.sun.star.table.CellContentType import EMPTY, VALUE, TEXT, FORMULA

    doc = XSCRIPTCONTEXT.getDocument()
    names = doc.Sheets.ElementNames
    tSheetName = 'Rezultatai'
    
    sheet = doc.CurrentController.ActiveSheet
    
    if not(tSheetName in names):
      tSheet = doc.Sheets.insertNewByName(tSheetName, 0) # make a new sheet
      
    tSheet = doc.Sheets[tSheetName]
    tSheet.IsVisible = True
    
    row = 1
    column = 1
    tRow = 1
    tColumn = 0
    
    cell = sheet[row,column]
    tCell = tSheet[tRow, tColumn]
    tCellName = tSheet[tRow, tColumn+1]
    
    while (cell.Type != EMPTY) :
        while (cell.Type != EMPTY) :
            if (int(cell.Value) > 0) :
                for i in range(int(cell.Value)) :
                  tCell.setString(sheet[row,0].getString())
                  tCellName.setString('{}'.format(sheet[0,column].getString()))
                  tRow += 1
                  tCell = tSheet[tRow, tColumn]
                  tCellName = tSheet[tRow, tColumn+1]
            column += 1
            cell = sheet[row,column] # advance column
        column = 1
        row += 1
        cell = sheet[row,column] # advance row
    return