Good Morning,
Thank you for your help. It is much appreciated. I am looking at the suggested code:
from __future__ import unicode_literals
import uno
import cx_Oracle
def checkDB():
wb = XSCRIPTCONTEXT.getDocument()
sht = wb.Sheets['Sheet1']
#connection = cx_Oracle.connect(user='????',password='????',dsn='????')
#cursor = connection.cursor()
oRange = wb.Sheets['sql'].getCellRangeByName('A1')
sqls= getCurrentRegion(oRange)
print(sqls)
# sht.getCellRangeByName('A1:AMJ1048576').clearContents(7)
# startCol = 0
# startRow = 0
# listSize=10000
# cursor.execute(sql)
# desc = cursor.description
# desc=list(zip(*desc))
# desc=desc[0]
# lastCol =len(desc)-1
# desc=[desc]
# sht.getCellRangeByPosition(startCol,startRow,lastCol,startRow ).setDataArray(desc)
# startRow=1
# while True:
# result= cursor.fetchmany(listSize)
# if result:
# lastRow=len(result)+startRow-1
# sht.getCellRangeByPosition(startCol,startRow,lastCol,lastRow).setDataArray(result)
# startRow=lastRow+1
# wb.store()
# else:
# break
# cursor.close()
# connection.close()
def getCurrentRegion(oRange):
oCursor = oRange.getSpreadSheet.createCursorByRange(oRange)
oCursor.collapseToCurrentRegion()
return oCursor
However I get the popup message:
Error during invoking function checkDB in module vnd.sun.star.tdoc:/1/Scripts/python/ModuleGetData.py (<class 'AttributeError'>: getSpreadSheet
File "D:\Program Files\LibreOffice\App\libreoffice\program\pythonscript.py", line 915, in invoke
ret = self.func( *args )
File "vnd.sun.star.tdoc:/1/Scripts/python/ModuleGetData.py", line 11, in checkDB
File "vnd.sun.star.tdoc:/1/Scripts/python/ModuleGetData.py", line 39, in getCurrentRegion
)
I modified getCurrentRegion to:
def getCurrentRegion(oRange):
oCursor = oRange.getSpreadSheet().createCursorByRange(oRange)
oCursor.collapseToCurrentRegion()
return oCursor
And I still get the same error. Thank you.