- Home /
"Load Data from Excel with Odbc" doesn't work in Unity 5 64bit
This works perfectly in Unity 4.6 32bit:
http://wiki.unity3d.com/index.php/Load_Data_from_Excel_2003
But Unity 5 64bit throws exception:
// Must be saved as excel 2003 workbook, not 2007, mono issue really
string con = "Driver={Microsoft Excel Driver (*.xls)}; DriverId=790; Dbq="+filetoread+";";
Debug.Log(con);
string yourQuery = "SELECT * FROM [Sheet1$]";
// our odbc connector
OdbcConnection oCon = new OdbcConnection(con);
// our command object
OdbcCommand oCmd = new OdbcCommand(yourQuery, oCon);
// table to hold the data
DataTable dtYourData = new DataTable("YourData");
// open the connection
oCon.Open();
The last line throws exception:
OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified System.Data.Odbc.OdbcConnection.Open ()
I have downloaded and installed Microsoft Access Database Engine 2010 Redistributable
http://www.microsoft.com/en-us/download/details.aspx?id=13255
But it still does not work.
Does anyone know a solution? Thank you!
Hi , same here it stopped working on Unity5 64 bit. $$anonymous$$aybe dll must be recompiled?
Looking forward for a solution
Best
Domenico
I have the same problem, has anybody found a solution for this yet? Thanks!
Did you configured a DSN?, if this is the case, it seems a bit to a native .net error where there's different architectures between your dsn and your client application. Have you tried creating the dsn as a 64 bit dsn?. Here's an article that explains a bit the confussion.
https://support.microsoft.com/es-es/kb/942976
Regards
I could not solve the problem...
I replaced Driver={$$anonymous$$icrosoft Excel Driver (.xls)}; with Driver={$$anonymous$$icrosoft Excel Driver (.xls, .xlsx, .xlsm, *.xlsb)}; and it connected, but the read failed...
Now I am using this library:
https://github.com/ExcelDataReader/ExcelDataReader
and it works really good :)
add excel.dll to you Assets folder
change unity project settings from using ".net 2 subset" to using ".net 2"
add "using Excel;" to the top of your class
use the code example that is on the ExcelDataReader github homepage: https://github.com/ExcelDataReader/ExcelDataReader (scroll down to "How to use")
Answer by rab · Jul 23, 2015 at 10:58 AM
Check the installed ODBC Drivers on your machine. Install the 64 bit version or use the 32 bit Unity version to use the 32 bit ODBC driver.
More info can be found here: Unity-Forum
Kind regards.
Answer by Reaksmey-Rt · Sep 16, 2015 at 01:22 PM
JinJin @centaurianmudpig :
I have a problem like you too and try to follow your advice but I really don't understand some point :
add excel.dll ( where can I find it ? )
Change unity project settings from using ".net 2 subset" to using".net 2"( I can't to find it in my ProjectSettings folder in my project).
So that Can you detail me more about it?
Oh... one thing I use Unity 5.1.2 p1(64 Bit) and Excel 2010. Thank you !
you only read my last comment. if you would read all my comments, you would see this:
Now I am using this library: https://github.com/ExcelDataReader/ExcelDataReader and it works really good :)
this is where you can download excel.dll
to access project settings, open Unity Editor and click on "Edit" and choose "Project settings" and "player"
http://www.theappguruz.com/app/uploads/2015/06/other-settings.png
look at Api compatibility level - change it to ".net 2"
JinJin did you ever try this method with a built project? I just recently tried and having a problem where ExcelReaderFactory.CreateOpenXmlReader() does not open the file, even though it works in the Editor, and I have confirmed the file paths are correct for the build.
Answer by MyUnitydream · Sep 12, 2018 at 05:21 AM
you can use Uni-Excel Package for Read, Write, and edit excel files