Difference between revisions of "Python/ViewingIntermediateResults"

From Apache OpenOffice Wiki
Jump to: navigation, search
([Python/Calc]: Viewing intermediate results)
Line 3: Line 3:
 
This script was published by kilorun and  at the [http://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=63067 OpenOffice Basic, Python, BeanShell, JavaScript Forum].
 
This script was published by kilorun and  at the [http://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=63067 OpenOffice Basic, Python, BeanShell, JavaScript Forum].
  
I'm developing a Python macro embedded in a Calc document to scrape data from various web pages and paste some results in cells in the spreadsheet.  
+
kilorun is developing a Python macro embedded in a Calc document to scrape data from various web pages and paste some results in cells in the spreadsheet.
 +
 
 +
It worked, but when starting the first version of the macro, we had wait until the macro has finished before seeing the results.
 +
 
 +
It has now been fixed with the following code:
 +
  
 
== Original code ==
 
== Original code ==

Revision as of 15:40, 3 September 2013


This script was published by kilorun and at the OpenOffice Basic, Python, BeanShell, JavaScript Forum.

kilorun is developing a Python macro embedded in a Calc document to scrape data from various web pages and paste some results in cells in the spreadsheet.

It worked, but when starting the first version of the macro, we had wait until the macro has finished before seeing the results.

It has now been fixed with the following code:


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" )


Process of the script

Personal tools