记录一下unity如何进行文件读取的操作
1.关于Excel文件的读取和写入:
这里的线索来源于买的一本书,书名《unity3D游戏开发(第二版)》,作者是宣雨松他这里面提到的使用一个DLL插件可以很方便的进行文件的读写创建等操作。Epplus这个可以在B站或者是VS的包管理也可以直接导入,或者需要的也可以找我。代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using OfficeOpenXml;
public class PrintExcel : MonoBehaviour
{
void Start()
{
LoadExcel();
AddExcel();
}
public static void LoadExcel()
{
string path = Application.dataPath + "/Excel/test.xlsx";
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (ExcelPackage excel=new ExcelPackage(fs))
{
ExcelWorksheets excelWorksheets = excel.Workbook.Worksheets;//获得所有表格
Debug.Log("表数:&