Unity3d读取excel

捣鼓了半天才弄出来,网是的资料层次不齐记录整理一下少走弯路。参考地址:Unity3D研究院之MAC&Windows跨平台解析Excel(六十五);

1.下载三个所需动态链接库,链接:https://pan.baidu.com/s/1vSR6b334YdH8RfLqtJDoRw 
提取码:8duf 
复制这段内容后打开百度网盘手机App,操作更方便哦

2.将下载下来的文件解压,将三个dll放到unity的Plugins文件夹下(没有创建,如图):

3.下面是测试代码(代码来自上面参考博文):

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 NewBehaviourScript : MonoBehaviour 
{
	void Start () 
	{		
		XLSX();
 
	}
 
	void XLSX()
	{ 
		FileStream stream = File.Open(Application.dataPath + "/UserLevel1.xlsx", FileMode.Open, FileAccess.Read);
		IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
		do{
			// sheet name
			Debug.Log(excelReader.Name);
			while (excelReader.Read()) {
				for (int i = 0; i < excelReader.FieldCount; i++) {
					string value = excelReader.IsDBNull(i) ? "" : excelReader.GetString(i);
					Debug.Log(value);
				}
			}
		}while(excelReader.NextResult());
	}
 
}

反正东西都是别人的,如果偷了谁的劳动成果没注明的,在下愿意被暴揍一顿。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值