哪里可以上传自己的php网站南宁网站seo大概多少钱
本文DEMO下载地址CSND下载,请使用U3D5.1.1版本打开,支持跨平台使用
- 跨平台读取
- Excel表的格式为XLSX
- 注意Run时关闭Excel编辑器,否则运行时报错
Demo示例代码
包含了一个只读方式的示例代码,其中还有write以及writeandread模式,可以进行表的读写操作
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using Excel;
using System.Data;public class ReadExcel:MonoBehaviour {public string ExcelPathName;void Start() {GameReadExcel(ExcelPathName);}/// <summary>/// 只读Excel方法/// </summary>/// <param name="ExcelPath"></param>/// <returns></returns>public static void GameReadExcel(string ExcelPath){FileStream stream = File.Open(Application.dataPath + ExcelPath, 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++){for (int j = 0; j < columns; j++){string nvalue = result.Tables[0].Rows[i][j].ToString();Debug.Log(nvalue);}}}
}