I'm trying to import some content directly from an excel file which the user selects from its local files. I've taken and modified code from the admin controller for retrieving the path/filename thru a nice file selection window.
The problem: I get only the filename of a locked temporary file, not the original filename. If I close the temporary file, to remove the lock, the file is automatically deleted... I would not mind to work with a temporary copy of the original file, but retrieving the original path/filename thru a similar file selection window would be prefered. How can this be achieved? Hans P.S. I'm using the xlrd module from http://pypi.python.org/pypi/xlrd ### viewer ### {{extend 'layout.html'}} <h1>excel_read.html template</h1> <div class='frame'> <h2>{{=t2.T('Select File')}}</h2> {{=FORM('File: ',INPUT(_type='file',_name='filename'),INPUT (_type='submit', _value='submit'))}} </div> <div class='frame'> {{=BEAUTIFY(response._vars)}} </div> ### controller ### def excel_read(): result={} if request.vars.filename != None: try: import xlrd # >>> can't locate the originally selected path/filename in request.vars.filename <<< book = xlrd.open_workbook(request.vars.filename.file.name) # >>> with a valid path/filename it works <<< book = xlrd.open_workbook('F:/Documents and Settings/Hans/ Desktop/test.xls') result['The number of worksheets is']=book.nsheets result["Worksheet name(s)"]= book.sheet_names() sh = book.sheet_by_index(0) result['sh.name']=sh.name result['sh.nrows']=sh.nrows result['sh.ncols']=sh.ncols result['Cell D30 is']=sh.cell_value(rowx=29, colx=3) for rx in range(sh.nrows): result['row ' + str(rx)]=sh.row(rx) except: response.flash = T('excel_read exception') return dict(result=result) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---