Help with displaying Debug.log info to chart on screen when press play. Excel chart to screen of game
I hope this has a simple solution but i am trying to display my chart from excel to the screen of my game. It can be as a GUI or simple text. When i run it the correct information displays at the Debug.log, but now i need it to appear on the screen of the game.
Here is my code, i want to display the Debug.Log info to the game screen.
using UnityEngine; using System.Collections; using System; using System.Data; using System.Data.Odbc;
public class EXCELREADER : MonoBehaviour {
// Use this for initialization
void Start()
{
readXLS(Application.dataPath + "/Book1.xls");
}
void OnGui()
{
}
// Update is called once per frame
void Update()
{
}
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 [Fanduel$]";
// 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++)
{
// lets see the column name then the data for that column!
Debug.Log(dtYourData.Columns[0].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[0].ColumnName].ToString() +
" | " + dtYourData.Columns[1].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[1].ColumnName].ToString() +
" | " + dtYourData.Columns[2].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[2].ColumnName].ToString() +
" | " + dtYourData.Columns[3].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[3].ColumnName].ToString() +
" | " + dtYourData.Columns[4].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[4].ColumnName].ToString() +
" | " + dtYourData.Columns[5].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[5].ColumnName].ToString() +
" | " + dtYourData.Columns[6].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[6].ColumnName].ToString() +
" | " + dtYourData.Columns[7].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[7].ColumnName].ToString() +
" | " + dtYourData.Columns[8].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[8].ColumnName].ToString() +
" | " + dtYourData.Columns[9].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[9].ColumnName].ToString() +
" | " + dtYourData.Columns[10].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[10].ColumnName].ToString() +
" | " + dtYourData.Columns[11].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[11].ColumnName].ToString() +
" | " + dtYourData.Columns[12].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[12].ColumnName].ToString() +
" | " + dtYourData.Columns[13].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[13].ColumnName].ToString() +
" | " + dtYourData.Columns[14].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[14].ColumnName].ToString() +
" | " + dtYourData.Columns[15].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[15].ColumnName].ToString() +
" | " + dtYourData.Columns[16].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[16].ColumnName].ToString() +
" | " + dtYourData.Columns[17].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[17].ColumnName].ToString() +
" | " + dtYourData.Columns[18].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[18].ColumnName].ToString() +
" | " + dtYourData.Columns[19].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[19].ColumnName].ToString() +
" | " + dtYourData.Columns[20].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[20].ColumnName].ToString() +
" | " + dtYourData.Columns[21].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[21].ColumnName].ToString() +
" | " + dtYourData.Columns[22].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[22].ColumnName].ToString() +
" | " + dtYourData.Columns[23].ColumnName + " : " + dtYourData.Rows[i][dtYourData.Columns[23].ColumnName].ToString());
}
}
}
}
Comment