Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active December 18, 2015 21:59
Show Gist options
  • Select an option

  • Save tsubaki/5851005 to your computer and use it in GitHub Desktop.

Select an option

Save tsubaki/5851005 to your computer and use it in GitHub Desktop.
Excel Data Reader - Read Excel files in .NETの使用サンプル
using UnityEngine;
using System.Collections;
using Excel;
using Excel.Core;
using System.IO;
public class LoadExcel : MonoBehaviour
{
[SerializeField]
string filePath;
void Start ()
{
// load file
FileStream stream = File.Open (filePath, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream); // xls
//IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader (stream); // xlsx
// load data
while (excelReader.Read()) {
Debug.Log( string.Format("{0}, {1}",
excelReader.GetString(0),
excelReader.GetString(1)));
}
// close
excelReader.Close ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment