Viewing intermediate results
From Apache OpenOffice Wiki
< Python
Revision as of 16:00, 3 September 2013 by Marcoagpinto (talk | contribs)
This script was published by kilorun and at the OpenOffice Basic, Python, BeanShell, JavaScript Forum.
This script is used to flush the threshold of a insertion process into the calc script when getting data from external sources like a website.
Macro to scrap data from various websites and insert it in a spreadsheet using Python, without having to wait until the macro had finished before seeing the results.
The forum doesn't mention this scrapping issue, it only focus on eliminating the "threshold of the process by updating the status indicator".
Original code
import time
def myTest3():
oDoc = XSCRIPTCONTEXT.getDocument()
oSheets = oDoc.getSheets()
mySheet = oSheets.getByName("Sheet1")
# set up Status Indicator
Controller = oDoc.getCurrentController()
DocFrame = Controller.getFrame()
oStatusIndicator = DocFrame.createStatusIndicator()
oStatusIndicator.start( "", 1 )
mySheet.getColumns().removeByIndex(0, 1)
oStatusIndicator.setText( "Process started" )
for i in range(0,5):
oStatusIndicator.setText( "Processing: " + str(i) )
mySheet.getCellByPosition(0,i).Value = i
time.sleep(1)
oStatusIndicator.setText( "Process finished" )