U3D 读取EXCEL

1、需要的dll文件:

  • Excel.dll   链接: https://pan.baidu.com/s/1zSRWWU-XLvt5jdZthas3zA 提取码: u97d
  • EPPlus.dll 链接: https://pan.baidu.com/s/1s3oXNpfGqeJ0DzK15wp6qg 提取码: rhcm
  • System.Data.dll 
  • ICSharpCode.SharpZipLib.dll
  • 18*.dll (避免发布后无法读取excel)
  • U3D 读取EXCEL

2、具体读取

  • 引入命名空间 :
    using Excel;
  • 读取
    FileStream stream = File.Open(Application.dataPath + "/StreamingAssets/AllExcel/"+excelname+".xlsx", FileMode.Open, FileAccess.Read);
    
    IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
    _result = excelReader.AsDataSet();
    _columns = _result.Tables[sheet].Columns.Count; //0  默认代表sheet1
    _rows    = _result.Tables[sheet].Rows.Count;