2using System.Collections.Generic;
4using NPOI.SS.UserModel;
5using NPOI.XSSF.UserModel;
10 public static Dictionary<string, string>
fallbackTypes =
new Dictionary<string, string>();
29 Debug.Log(
"ImportExcel source:" + source?.ToString() +
" Path:" + pathToExcelFile);
30 using FileStream @is = File.Open(pathToExcelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
31 XSSFWorkbook xSSFWorkbook =
new XSSFWorkbook((Stream)@is);
32 for (
int i = 0; i < xSSFWorkbook.NumberOfSheets; i++)
34 ISheet sheetAt = xSSFWorkbook.GetSheetAt(i);
35 if (sheetAt.SheetName != sheetName)
39 Debug.Log(
"Importing Sheet:" + sheetName);
42 if (!source.
ImportData(sheetAt,
new FileInfo(pathToExcelFile).Name, overwrite:
true))
47 Debug.Log(
"Imported " + sheetAt.SheetName);
52 Debug.LogError(
"[Error] Skipping import " + sheetAt.SheetName +
" :" + ex.Message +
"/" + ex.Source +
"/" + ex.StackTrace);
static SourceManager sources
static void RegisterSerializedTypeFallback(string nameAssembly, string nameType, string nameFallbackType)
static Dictionary< string, string > fallbackTypes
static void OnModsActivated()
static void ImportExcel(string pathToExcelFile, string sheetName, SourceData source)
override bool ImportData(ISheet sheet, string bookname, bool overwrite=false)