I am using this script that is working. But in unity i can’t get the strings from the shells. The are greek characters like “Κάλη μέρα” but i get “??? ???”.
How i can get thisd work?
i try this but din;t change anything.
string con = “Driver={Microsoft Excel Driver (*.xls)};characterEncoding=UTF-8;CharSet=UTF-8;DriverId=790; Dbq=”+filetoread+“;”;
the script i get it from :
http://wiki.unity3d.com/index.php?title=Load_Data_from_Excel_2003
void readXLS( string filetoread)
{
// 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();
// lets use a datareader to fill that table!
OdbcDataReader rData = oCmd.ExecuteReader();
// now lets blast that into the table by sheer man power!
dtYourData.Load(rData);
// close that reader!
rData.Close();
// close your connection to the spreadsheet!
oCon.Close();
// wow look at us go now! we are on a roll!!!!!
// lets now see if our table has the spreadsheet data in it, shall we?
if(dtYourData.Rows.Count > 0)
{
// do something with the data here
// but how do I do this you ask??? good question!
for (int i = 0; i < dtYourData.Rows.Count; i++)
{
// for giggles, lets see the column name then the data for that column!
Debug.Log(dtYourData.Columns[0].ColumnName + " : " + dtYourData.Rows*[dtYourData.Columns[0].ColumnName].ToString() +*
" | " + dtYourData.Columns[1].ColumnName + " : " + dtYourData.Rows*[dtYourData.Columns[1].ColumnName].ToString() +*
" | " + dtYourData.Columns[2].ColumnName + " : " + dtYourData.Rows*[dtYourData.Columns[2].ColumnName].ToString());*
* }*
* }*
* }*