read an excel file works only in the editor,not in the build

hello,
here’s my code for read from excel file.
editor works fine but in the build the excel file is not read.

when i work in the editor the file is in the folder

c:\projectname\1.xls

in the build:

c:\1.xls
c:\project_Data\ 1.xls

using UnityEngine;
using System.Collections;
using System; 
using System.Data; 
using System.Data.Odbc; 

public class ExcelReader : MonoBehaviour
{
    String something;
    public String Filename="1";
    
    void Start ()
    {
        readXLS(Filename); 
    }
 
    void readXLS(String Filename)
    {
        // Must be saved as excel 2003 workbook, not 2007, mono issue really
        string con = "Driver={Microsoft Excel Driver (*.xls)}; DriverId=790; Dbq="+Filename+";";
        string yourQuery = "SELECT * FROM [Foglio1$]"; 

        OdbcConnection oCon = new OdbcConnection(con); 
        
        OdbcCommand oCmd = new OdbcCommand(yourQuery, oCon);

        DataTable dtYourData = new DataTable("YourData"); 
        
        oCon.Open(); 
        
        OdbcDataReader rData = oCmd.ExecuteReader(); 
        
        dtYourData.Load(rData); 
        
        rData.Close(); 
        
        oCon.Close(); 
        
        if(dtYourData.Rows.Count > 0) 
        { 
            prova = dtYourData.Rows[0][dtYourData.Columns[1].ColumnName].ToString(); 
            if (something == "DESTROY!")
                Destroy(GameObject.Find("Cube"));
            print(something);
        }
    }
}

The build tries to keep small by stripping out anything it doesn’t know you’re using. really nice feature. It checks for anything on a gameObject, Material … and anything which has been dragged into a public variable in an Inspector. But, it can’t “see” things which are only accessed in code.

So, it’s probably purposely not including your file.

The Unity work-around for that is to put anything like that into a folder named Resources. Anything in there is always included in the build. Not sure if caps matter, or it needs to be a single top-level Resources folder. But you should be able to just examine the new build-folder and see if it’s there.

Read excel files by the use of excel repair file

Apply http://www.excel2007repair.excelrepairtoolbox.com contains a lot of effective solutions