前提电脑里面有office2007 只适配xlsx
void Start ()
{
System.Reflection.Assembly curPath = System.Reflection.Assembly.GetExecutingAssembly();
try
{
E2j();
}
catch (IOException e) {
Debug.Log("-"+e);
}
}
void e2j()
{
SimpleJSON.JSONArray data = new SimpleJSON.JSONArray();
FileStream stream = File.Open(GetExcelPath, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
DataSet result = excelReader.AsDataSet();
int columns = result.Tables[0].Columns.Count;
int rows = result.Tables[0].Rows.Count;
for(int i = 1; i< rows; i++)//行起点
{
SimpleJSON.JSONClass dataONE = new SimpleJSON.JSONClass();
for (int j =0; j < columns; j++)//列
{
string row = result.Tables[0].Rows[0][j].ToString();
string nvalue = result.Tables[0].Rows[i][j].ToString();
dataONE[row] = nvalue;
Debug.Log(row);
UI.text = nvalue;
}
Debug.Log(dataONE);
data.Add(dataONE);
}
IEM_FileTools.FielCopyCreat(IOlocaPath,data.ToString());
}