Ask Your Question
0

possible to run calc non-interactively? [closed]

asked 2018-03-07 02:45:52 +0200

Phillip_M_Feldman gravatar image

updated 2018-03-07 02:46:30 +0200

I would like to invoke calc so that it runs non-interactively and does the following:

(1) Open the specified workbook.

(2) Modify the values of one or more cells.

(3) Recalculate cells whose values depend on values in cells modified in (2).

(4) Save and close the workbook.

Can this be done? If so, how?

Phillip M. Feldman

Home Page: http://phillipmfeldman.org

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2021-04-23 03:46:18.043846

1 Answer

Sort by » oldest newest most voted
0

answered 2018-03-08 03:08:35 +0200

Jim K gravatar image

One approach is to run a macro stored in the document or in My Macros. Here is an example in Basic:

Sub ChangeSomeValues
    oDoc = ThisComponent
    oSheet = oDoc.getSheets().getByIndex(0)
    oCell = oSheet.GetCellRangeByName("A1")
    oCell.setValue(oCell.getValue()+1)
    oCell = oSheet.GetCellRangeByName("A2")
    oCell.setValue(42)
    oDoc.store()
    oDoc.close(True)
End Sub

Then call it like this.

soffice "change values noninteractively.ods" "vnd.sun.star.script:Standard.Module1.ChangeSomeValues?language=Basic&location=document"

The example document: change values noninteractively.ods

While this is not interactive, the window will still appear. To hide the window, see my answer at https://superuser.com/questions/11358....

Another approach is to use an external python script or a live python shell. To do this, start LibreOffice listening. A good tutorial is at http://christopher5106.github.io/offi....

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-03-07 02:45:52 +0200

Seen: 158 times

Last updated: Mar 08 '18