import os
import uno
import re
import datetime
import string
def aisversion():
Doc = XSCRIPTCONTEXT.getDocument()
displayDir = os.path.dirname(Doc.getURL())
ctx = uno.getComponentContext()
smgr = ctx.ServiceManager
folderPicker = smgr.createInstanceWithContext('com.sun.star.ui.dialogs.FolderPicker', ctx)
folderPicker.setDisplayDirectory(displayDir)
result = folderPicker.execute()
SelectPath = uno.pyuno.fileUrlToSystemPath(folderPicker.getDirectory())
if result:
files = os.listdir(SelectPath)
else:
files = []
sheets = Doc.getSheets()
sheet = Doc.getCurrentController().getActiveSheet()
cell=0
rows = 3
for i in files:
fs = SelectPath+'//'+i
if os.path.isdir(fs.replace('//','////')):
continue
filename = i.split('.')
if filename[-1].upper() !='SQL':
continue
xSearchDescr = sheet.createSearchDescriptor()
xSearchDescr.SearchString = filename[-2]
xSearchDescr.SearchCaseSensitive = False
xSearchDescr.SearchWords = True
xFound = shee