Page 1 of 1

DC_Excel2Array with MS Excel 2013

Posted: Thu Oct 27, 2016 10:52 am
by unixkd
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

Re: DC_Excel2Array with MS Excel 2013

Posted: Thu Oct 27, 2016 12:27 pm
by rdonnay
What is the error?

Re: DC_Excel2Array with MS Excel 2013

Posted: Thu Oct 27, 2016 1:08 pm
by unixkd
Excel2Array.png
Excel2Array.png (368.72 KiB) Viewed 7387 times

Re: DC_Excel2Array with MS Excel 2013

Posted: Thu Oct 27, 2016 5:01 pm
by rdonnay
This is what I found in a Google search:
Re: "Server Threw an Exception" Error When Creating an Excel File
Nov 09, 2008 07:03 PM|LINK

I had a similar issue a couple of years ago and I solved the issue by installing Excel on the server. I don't do much work with Excel so maybe there is an easier way, possibly just adding the correct dlls. But when I hear "it worked on my machine but not the server" I can only assume the only thing the server doesn't have that ur machine has is Excel, and that's what fixed my issue. Give it a shot unless you find a better solution and if you do please post the answer for others.
Correct Answer
by Andrew Workman on May 2, 2013 8:13 AM
OK, found the solution. It was the .net framework. 3.0 is the minimum requirement for EPDM to function. However, there is something int he 3.... framework that is NOT included in the 4.... framework. So it is not completely backwards compatible. a 4.0 framework install will not cover all frameworks before it. We installed 3.5 on her machine, and it functions perfectly now. so, if anyone else has a similar issue, make sure you have some version of 3.... framework installed.

Re: DC_Excel2Array with MS Excel 2013

Posted: Thu Oct 27, 2016 6:35 pm
by unixkd
Thanks.

I will try some options