Exemple #1
0
def _attempt_open_excel():
    if _attempt_open_excel.result is None:
        from pyutilib.excel.spreadsheet_win32com import (
            ExcelSpreadsheet_win32com)
        try:
            tmp = ExcelSpreadsheet_win32com()
            tmp._excel_dispatch()
            tmp._excel_quit()
            _attempt_open_excel.result = True
        except:
            _attempt_open_excel.result = False
    return _attempt_open_excel.result
 def __new__(cls, *args, **kwds):
     #
     # Note that this class returns class instances rather than
     # class types.  This is because these classes are not
     # subclasses of ExcelSpreadsheet, and thus the __init__
     # method will not be called unless we construct the
     # class instances here.
     #
     ctype = kwds.pop('ctype', None)
     if ctype == 'xlrd':
         return ExcelSpreadsheet_xlrd(*args, **kwds)
     if ctype == 'win32com':
         return ExcelSpreadsheet_win32com(*args, **kwds)
     if ctype == 'openpyxl':
         return ExcelSpreadsheet_openpyxl(*args, **kwds)
     #
     if _xlrd:
         return ExcelSpreadsheet_xlrd(*args, **kwds)
     if _win32com:
         return ExcelSpreadsheet_win32com(*args, **kwds)
     if _openpyxl:
         return ExcelSpreadsheet_openpyxl(*args, **kwds)
     #
     return super(ExcelSpreadsheet, cls).__new__(cls)
Exemple #3
0
    unicode
except:

    def unicode(x):
        return x


try:
    from win32com.client.dynamic import Dispatch
    from pyutilib.excel.spreadsheet_win32com import ExcelSpreadsheet_win32com
    _win32com_available = True  #pragma:nocover
except:
    _win32com_available = False  #pragma:nocover
_excel_available = False  #pragma:nocover
if _win32com_available:
    tmp = ExcelSpreadsheet_win32com()
    try:
        tmp._excel_dispatch()
        tmp._excel_quit()
        _excel_available = True
    except:
        pass
try:
    import xlrd
    _xlrd_available = True
except:
    _xlrd_available = False
try:
    import openpyxl
    _openpyxl_available = True
except: