Last active
December 18, 2015 21:59
-
-
Save tsubaki/5851005 to your computer and use it in GitHub Desktop.
Excel Data Reader - Read Excel files in .NETの使用サンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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