/// <summary>
    /// Setups the sheet list.
    /// </summary>
    /// <param name="book">Book.</param>
    void SetupSheetList()
    {
        sheetNameList.Clear();
        sheetList.Clear();

        for (int i = 0; i < book.NumberOfSheets; ++i)
        {
            ISheet s = book.GetSheetAt(i);
            ExcelSheetParameter sht = new ExcelSheetParameter();
            sht.sheetName = s.SheetName;
            sht.isEnable  = EditorPrefs.GetBool(s_key_prefix + fileName + ".sheet." + sht.sheetName, true);
            sheetNameList.Add(s.SheetName);
            sheetList.Add(sht);
        }
    }
    static void ExportExcelToAssetbundle()
    {
        foreach (Object obj in Selection.objects)
        {
            var window = ScriptableObject.CreateInstance <ExcelImporterMaker>();
            window.filePath = AssetDatabase.GetAssetPath(obj);
            window.fileName = Path.GetFileNameWithoutExtension(window.filePath);


            using (FileStream stream = File.Open(window.filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                IWorkbook book = null;
                if (Path.GetExtension(window.filePath) == ".xls")
                {
                    book = new HSSFWorkbook(stream);
                }
                else
                {
                    book = new XSSFWorkbook(stream);
                }

                for (int i = 0; i < book.NumberOfSheets; ++i)
                {
                    ISheet s = book.GetSheetAt(i);
                    ExcelSheetParameter sht = new ExcelSheetParameter();
                    sht.sheetName = s.SheetName;
                    sht.isEnable  = EditorPrefs.GetBool(s_key_prefix + window.fileName + ".sheet." + sht.sheetName, true);
                    window.sheetList.Add(sht);
                }

                ISheet sheet = book.GetSheetAt(0);

                window.className = EditorPrefs.GetString(s_key_prefix + window.fileName + ".className", "Entity_" + sheet.SheetName);

                window.sepalateSheet = EditorPrefs.GetBool(s_key_prefix + window.fileName + ".separateSheet");

                IRow titleRow = sheet.GetRow(0);
                IRow dataRow  = sheet.GetRow(1);
                for (int i = 0; i < titleRow.LastCellNum; i++)
                {
                    ExcelRowParameter lastParser = null;
                    ExcelRowParameter parser     = new ExcelRowParameter();
                    parser.name    = titleRow.GetCell(i).StringCellValue;
                    parser.isArray = parser.name.Contains("[]");
                    if (parser.isArray)
                    {
                        parser.name = parser.name.Remove(parser.name.LastIndexOf("[]"));
                    }

                    ICell cell = dataRow.GetCell(i);

                    // array support
                    if (window.typeList.Count > 0)
                    {
                        lastParser = window.typeList [window.typeList.Count - 1];
                        if (lastParser.isArray && parser.isArray && lastParser.name.Equals(parser.name))
                        {
                            // trailing array items must be the same as the top type
                            parser.isEnable          = lastParser.isEnable;
                            parser.type              = lastParser.type;
                            lastParser.nextArrayItem = parser;
                            window.typeList.Add(parser);
                            continue;
                        }
                    }

                    if (cell.CellType != CellType.Unknown && cell.CellType != CellType.Blank)
                    {
                        parser.isEnable = true;

                        try
                        {
                            if (EditorPrefs.HasKey(s_key_prefix + window.fileName + ".type." + parser.name))
                            {
                                parser.type = (ValueType)EditorPrefs.GetInt(s_key_prefix + window.fileName + ".type." + parser.name);
                            }
                            else
                            {
                                string sampling = cell.StringCellValue;
                                parser.type = ValueType.STRING;
                            }
                        } catch
                        {
                        }
                        try
                        {
                            if (EditorPrefs.HasKey(s_key_prefix + window.fileName + ".type." + parser.name))
                            {
                                parser.type = (ValueType)EditorPrefs.GetInt(s_key_prefix + window.fileName + ".type." + parser.name);
                            }
                            else
                            {
                                double sampling = cell.NumericCellValue;
                                parser.type = ValueType.DOUBLE;
                            }
                        } catch
                        {
                        }
                        try
                        {
                            if (EditorPrefs.HasKey(s_key_prefix + window.fileName + ".type." + parser.name))
                            {
                                parser.type = (ValueType)EditorPrefs.GetInt(s_key_prefix + window.fileName + ".type." + parser.name);
                            }
                            else
                            {
                                bool sampling = cell.BooleanCellValue;
                                parser.type = ValueType.BOOL;
                            }
                        } catch
                        {
                        }
                    }

                    window.typeList.Add(parser);
                }

                window.Show();
            }
        }
    }
	static void ExportExcelToAssetbundle ()
	{
		foreach (Object obj in Selection.objects) {
			
		
			var window = ScriptableObject.CreateInstance<ExcelImporterMaker> ();
			window.filePath = AssetDatabase.GetAssetPath (obj);
			window.fileName = Path.GetFileNameWithoutExtension (window.filePath);
		
		
			using (FileStream stream = File.Open (window.filePath, FileMode.Open, FileAccess.Read)) {
			
				IWorkbook book = new HSSFWorkbook (stream);

				for(int i = 0; i < book.NumberOfSheets; ++i) {
					ISheet s = book.GetSheetAt (i);
					ExcelSheetParameter sht = new ExcelSheetParameter ();
					sht.sheetName = s.SheetName;
					sht.isEnable  = EditorPrefs.GetBool(s_key_prefix + window.fileName + ".sheet."+ sht.sheetName, true);
					window.sheetList.Add( sht );
				}
			
				ISheet sheet = book.GetSheetAt (0);

				window.className = EditorPrefs.GetString (s_key_prefix + window.fileName + ".className", "Entity_" + sheet.SheetName);

				IRow titleRow = sheet.GetRow (0);
				IRow dataRow = sheet.GetRow (1);
				for (int i=0; i < titleRow.LastCellNum; i++) {
					ExcelRowParameter lastParser = null;
					ExcelRowParameter parser = new ExcelRowParameter ();
					parser.name = titleRow.GetCell (i).StringCellValue;
					parser.isArray = parser.name.Contains("[]");
					if( parser.isArray ) {
						parser.name = parser.name.Remove(parser.name.LastIndexOf("[]"));
					}

					ICell cell = dataRow.GetCell (i);

//					if(cell == null) {
//						continue;
//					}

					// array support
					if( window.typeList.Count > 0 ) {
						lastParser = window.typeList[window.typeList.Count-1];
						if( lastParser.isArray && parser.isArray && lastParser.name.Equals( parser.name ) ) {
							// trailing array items must be the same as the top type
							parser.isEnable = lastParser.isEnable;
							parser.type = lastParser.type;
							lastParser.nextArrayItem = parser;
							window.typeList.Add (parser);
							continue;
						}
					}
				
					if (cell.CellType != CellType.Unknown && cell.CellType != CellType.BLANK) {
						parser.isEnable = true;

						try {
							if(EditorPrefs.HasKey(s_key_prefix + window.fileName + ".type."+ parser.name)) {
								parser.type = (ValueType)EditorPrefs.GetInt(s_key_prefix + window.fileName + ".type."+ parser.name);
							} else {
								string sampling = cell.StringCellValue;
								parser.type = ValueType.STRING;
							}
						} catch {
						}
						try {
							if(EditorPrefs.HasKey(s_key_prefix + window.fileName + ".type."+ parser.name)) {
								parser.type = (ValueType)EditorPrefs.GetInt(s_key_prefix + window.fileName + ".type."+ parser.name);
							} else {
								double sampling = cell.NumericCellValue;
								parser.type = ValueType.DOUBLE;
							}
						} catch {
						}
						try {
							if(EditorPrefs.HasKey(s_key_prefix + window.fileName + ".type."+ parser.name)) {
								parser.type = (ValueType)EditorPrefs.GetInt(s_key_prefix + window.fileName + ".type."+ parser.name);
							} else {
								bool sampling = cell.BooleanCellValue;
								parser.type = ValueType.BOOL;
							}
						} catch {
						}
					}
				
					window.typeList.Add (parser);
				}
			
				window.Show ();
			}
		}
	}