# Is it possible to insert a running clock in a Calc spreadsheet cell?

Is it possible to insert a running clock in a Calc spreadsheet cell? Digital or Analog are both usable.

edit retag close merge delete

1

Hello @Super_C,

Yes in theory, you could make a threaded timer in Python with an interval of 1 second, then update the value in your Calc cell to the current time. ( i have not tried this myself yet ).

( 2017-11-29 00:00:03 +0100 )edit

Sort by » oldest newest most voted

There is a way to do it without macros, that I did a time ago for a question in the Spanish AOo forum.

In a cell introduce =NOW(), give a name to it like 'timer'.
Save the file.
Select the cell where to introduce the clock.
Create a Menu/Sheet/Link to external data, select as data source the own file.
Select the 'timer' in the 'Available Tables/Ranges'
Mark Update interval and fix the seconds you like for update the clock.
Ok

Sample timer.ods

more

1

+1 awesome trick!

( 2017-11-29 01:04:36 +0100 )edit

One disadvantage is that it stops working if the file is renamed, whereas a macro would not have this problem. However, avoiding macros is an advantage, so it's a tradeoff. Anyway, I did not realize before that this solution can work even with reference to the same file.

( 2017-11-29 06:00:22 +0100 )edit

As @librebel mentioned, one way to do this is with a threaded Python macro. From my answer at https://stackoverflow.com/a/44988206/...:

Assign keep_recalculating_thread to the Open Document event.

import time
import uno

t.start()

def keep_recalculating():
oDoc = XSCRIPTCONTEXT.getDocument()
while hasattr(oDoc, 'calculateAll'):
oDoc.calculateAll()
time.sleep(5)



Instead of calculateAll(), I also tried updating a single cell containing NOW() as recommended here. My hope was that only a single cell would need to be changed.

oCell.setFormula(oCell.getFormula() + " ")


This worked too, but it made all cells with NOW() and RAND()change anyway, so it does not seem to be any more efficient. See https://help.libreoffice.org/Calc/Rec....

more