import pcop import pydcop app = pydcop.anyAppCalled("kspread") doc = app.default.getDocuments()[0] table = doc.map().tables()[0] table.cell( 1, 1 ).setValue( 1 ) x = 2 while x < 5: y = 2 while y < 5: previousCell = table.cell( x - 1, y - 1 ) cell = table.cell( x, y ) cell.setValue( previousCell.value() + 1.0 ) y = y + 1 x = x + 1