DC_Excel2Array with MS Excel 2013
Posted: Thu Oct 27, 2016 10:52 am
Hi Roger
DC_Excel2Array() function give error in the line indicated below while using Excel 2013 work fine with Excel 2010
FUNCTION DC_Excel2Array( cExcelFile, bEval )
LOCAL oExcel, oBook, aValues
#if XPPVER > 1900000
// Create the "Excel.Application" object
oExcel := CreateObject("Excel.Application")
IF Empty( oExcel )
DC_WinAlert( "Excel is not installed" )
RETURN nil
ENDIF
#else
DC_WinAlert('This feature is available in Xbase++ 1.9 and later only!')
RETURN nil
#endif
oExcel:Visible := .f.
// Load a Workbook from an .XLS file
IF !FExists(cExcelFile)
DC_WinAlert( 'File does not exist:' + Chr(13) + cExcelFile )
RETURN nil
ENDIF
oBook := oExcel:Workbooks:Open(cExcelFile) /// ************** GIVE ERROR HERE ****************************************************
IF Valtype(bEval) == 'B'
Eval( bEval, oExcel, oBook )
ENDIF
aValues := oBook:workSheets(1):usedRange:value
oBook:close()
oBook:destroy()
// Quit Excel
oExcel:Quit()
oExcel:Destroy()
RETURN aValues
DC_Excel2Array() function give error in the line indicated below while using Excel 2013 work fine with Excel 2010
FUNCTION DC_Excel2Array( cExcelFile, bEval )
LOCAL oExcel, oBook, aValues
#if XPPVER > 1900000
// Create the "Excel.Application" object
oExcel := CreateObject("Excel.Application")
IF Empty( oExcel )
DC_WinAlert( "Excel is not installed" )
RETURN nil
ENDIF
#else
DC_WinAlert('This feature is available in Xbase++ 1.9 and later only!')
RETURN nil
#endif
oExcel:Visible := .f.
// Load a Workbook from an .XLS file
IF !FExists(cExcelFile)
DC_WinAlert( 'File does not exist:' + Chr(13) + cExcelFile )
RETURN nil
ENDIF
oBook := oExcel:Workbooks:Open(cExcelFile) /// ************** GIVE ERROR HERE ****************************************************
IF Valtype(bEval) == 'B'
Eval( bEval, oExcel, oBook )
ENDIF
aValues := oBook:workSheets(1):usedRange:value
oBook:close()
oBook:destroy()
// Quit Excel
oExcel:Quit()
oExcel:Destroy()
RETURN aValues