Mit dem FlexReader-Plugin können Sie Daten in Excel unter webgl auslesen
using System.Collections;
using FlexFramework.Excel;
using UnityEngine;
using UnityEngine.Networking;
public class ReadXlsx : MonoBehaviour
{
void Start()
{
StartCoroutine(IELoadXlsx());
}
IEnumerator IELoadXlsx()
{
string path = Application.streamingAssetsPath + "/Data.xlsx";
yield return null;
using (UnityWebRequest webRequest = UnityWebRequest.Get(path))
{
yield return webRequest.SendWebRequest();
Debug.Log("Code:" + webRequest.responseCode);
if (webRequest.responseCode == 200)
{
WorkBook book = new WorkBook(webRequest.downloadHandler.data);
for (int i = 0; i < book[0].Rows.Count; i++)
{
for (int j = 0; j < book[0].Rows[i].Cells.Count; j++)
{
Debug.Log("数据:" + book[0].Rows[i].Cells[j].Text);
}
}
}
}
}
}
Operationsergebnis
Stellen Sie sicher, dass Sie diese 3 DLLs hinzufügen
Portal – der Quellcode enthält Plug-Ins. Wenn Sie ihn benötigen, können Sie ihn sich ansehen.