private void OnEnable()
        {
            dataPath = Application.dataPath;
            dataPath = dataPath.Substring(0, dataPath.Length - "Assets".Length);

            selectPrefKey = string.Format("{0}SingleOrMultiSelectPrefKey", EditorTools.GetCompanyName());
            isSingleFile  = preSelect = EditorPrefs.GetBool(selectPrefKey, true);

            excelPath    = SQLite3Path.GetSingleExcelPath();
            excelFolder  = SQLite3Path.GetExcelFolder();
            scriptFolder = SQLite3Path.GetScriptSaveFolder();
            dbPath       = SQLite3Path.GetDbSavePath();

            centerTittleStyle = new GUIStyle
            {
                fontStyle = FontStyle.Bold,
                alignment = TextAnchor.MiddleCenter,
                normal    = new GUIStyleState
                {
                    textColor = EditorGUIUtility.isProSkin ? new Color(.7f, .7f, .7f) : Color.black
                }
            };


            leftTittleStyle = new GUIStyle
            {
                fontStyle = FontStyle.Bold,
                alignment = TextAnchor.MiddleLeft,
                normal    = new GUIStyleState
                {
                    textColor = EditorGUIUtility.isProSkin ? new Color(.7f, .7f, .7f) : Color.black
                }
            };
        }
        private void OnGUI()
        {
            GUILayout.Label("Excel To SQLite3 Table", EditorStyles.boldLabel);

            EditorGUILayout.BeginVertical("box");
            {
                EditorGUILayout.BeginVertical("box");
                {
                    GUILayout.BeginHorizontal();
                    {
                        isSingleFile = EditorGUILayout.ToggleLeft("Single Excel", isSingleFile, GUILayout.Width(245));
                        isSingleFile = !EditorGUILayout.ToggleLeft("Excel Directory", !isSingleFile, GUILayout.Width(245));

                        if (preSelect != isSingleFile)
                        {
                            TableData[][] temp = tableData;
                            tableData    = preTableData;
                            preTableData = temp;

                            preSelect = isSingleFile;

                            EditorPrefs.SetBool(selectPrefKey, isSingleFile);
                        }
                    }

                    GUILayout.EndHorizontal();
                    GUILayout.Space(15);

                    if (isSingleFile)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            excelPath = EditorGUILayout.TextField("Excel Path", excelPath, GUILayout.Width(440));
                            if (GUILayout.Button("Select", GUILayout.MaxWidth(88)))
                            {
                                excelPath = SQLite3Path.SelectExcelPath();
                            }
                        }
                        GUILayout.EndHorizontal();

                        if (GUILayout.Button("Preview"))
                        {
                            if (string.IsNullOrEmpty(excelPath))
                            {
                                EditorUtility.DisplayDialog("Tips", "Please select an excel file first.", "OK");
                            }
                            else
                            {
                                LoadExcel(Path.Combine(dataPath, excelPath));
                            }
                        }
                    }
                    else
                    {
                        GUILayout.BeginHorizontal();
                        {
                            excelFolder = EditorGUILayout.TextField("Excel Directory", excelFolder, GUILayout.Width(440));
                            if (GUILayout.Button("Select", GUILayout.MaxWidth(88)))
                            {
                                excelFolder = SQLite3Path.SelectExcelFolder();
                            }
                        }
                        GUILayout.EndHorizontal();

                        if (GUILayout.Button("Preview"))
                        {
                            if (string.IsNullOrEmpty(excelFolder))
                            {
                                EditorUtility.DisplayDialog("Tips", "Please select a directory where excel is stored.", "OK");
                            }
                            else
                            {
                                LoadExcelDirectory(Path.Combine(dataPath, excelFolder));
                            }
                        }
                    }
                }
                EditorGUILayout.EndVertical();

                if (null != tableData)
                {
                    sheetLength = tableData.Length;
                    //config = isSingleFile ? singlePathConfig : multiPathConfig;
                    EditorGUILayout.BeginVertical("box");
                    {
                        GUILayout.BeginHorizontal();
                        {
                            dbPath = EditorGUILayout.TextField("Database Save Path", dbPath, GUILayout.Width(440));
                            if (GUILayout.Button("Select", GUILayout.MaxWidth(88)))
                            {
                                dbPath = SQLite3Path.SelectDbSavePath();
                            }
                        }
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        {
                            scriptFolder = EditorGUILayout.TextField("Script Save Directory", scriptFolder, GUILayout.Width(440));
                            if (GUILayout.Button("Select", GUILayout.MaxWidth(88)))
                            {
                                scriptFolder = SQLite3Path.SelectScriptSaveFolder();
                            }
                        }
                        GUILayout.EndHorizontal();


                        if (!isSingleFile && sheetLength > 1)
                        {
                            if (GUILayout.Button("Create All"))
                            {
                                try
                                {
                                    if (string.IsNullOrEmpty(dbPath))
                                    {
                                        EditorUtility.DisplayDialog("Tips", "Please select the storage location of the database.", "OK");
                                    }
                                    else
                                    {
                                        if (string.IsNullOrEmpty(scriptFolder))
                                        {
                                            EditorUtility.DisplayDialog("Tips", "Please select the storage location of the script.", "OK");
                                        }
                                        else
                                        {
                                            for (int i = 0; i < sheetLength; i++)
                                            {
                                                rowLength = tableData[i].Length;
                                                for (int j = 0; j < rowLength; j++)
                                                {
                                                    if (tableData[i][j].IsEnable)
                                                    {
                                                        progressValue = 1.0f;
                                                        if (tableData[i][j].IsNeedCreateScript)
                                                        {
                                                            progressValue = .5f;
                                                            EditorUtility.DisplayProgressBar("Convert excel to C# script...", "Convert excel named: " + tableData[i][j].TableName, i * progressValue / sheetLength);
                                                            ScriptWriter.Writer(string.Format("{0}{1}.cs", Path.Combine(dataPath, scriptFolder), tableData[i][j].TableName), ref tableData[i][j]);
                                                        }
                                                        EditorUtility.DisplayProgressBar("Convert excel to SQLite3 table...", "Convert excel named: " + tableData[i][j].TableName, i * .5f / sheetLength);

                                                        SQLite3Creator.Creator(ref tableData[i][j], Path.Combine(dataPath, dbPath));
                                                    }
                                                }
                                            }
                                            EditorUtility.DisplayProgressBar("CompileCSharp Script...", "Please Waiting...", 1.5f);

                                            EditorUtility.ClearProgressBar();

                                            EditorUtility.DisplayDialog("Tips", "Convert excel to SQLite3 table finished.", "OK");
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    EditorUtility.DisplayDialog("Error", "Convert excel to SQLite3 table has an error:" + ex.Message, "OK");
                                }
                                Close();
                            }
                        }
                    }
                    EditorGUILayout.EndVertical();

                    scrollPos = GUILayout.BeginScrollView(scrollPos);
                    for (int i = 0; i < sheetLength; ++i)
                    {
                        if (null != tableData[i])
                        {
                            rowLength = tableData[i].Length;
                            for (int j = 0; j < rowLength; ++j)
                            {
                                EditorGUILayout.BeginVertical("box");
                                {
                                    GUILayout.BeginHorizontal();
                                    {
                                        tableData[i][j].TableName = EditorGUILayout.TextField("Table Name",
                                                                                              tableData[i][j].TableName, GUILayout.Width(440));

                                        tableData[i][j].IsEnable = EditorGUILayout.ToggleLeft("Enable",
                                                                                              tableData[i][j].IsEnable, GUILayout.Width(88));
                                    }
                                    GUILayout.EndHorizontal();

                                    if (tableData[i][j].IsEnable)
                                    {
                                        GUILayout.Space(10);
                                        EditorGUILayout.BeginVertical("box");
                                        {
                                            GUILayout.BeginHorizontal();
                                            {
                                                EditorGUILayout.LabelField("Property Name", centerTittleStyle, GUILayout.Width(104));
                                                GUILayout.Space(4);
                                                EditorGUILayout.LabelField("Property Describe", centerTittleStyle, GUILayout.Width(286));
                                                GUILayout.Space(4);
                                                EditorGUILayout.LabelField("SQLite3 Type", centerTittleStyle, GUILayout.Width(104));
                                            }
                                            GUILayout.EndHorizontal();
                                            GUILayout.Space(10);

                                            columnLength = tableData[i][j].ColumnName.Length;
                                            for (int k = 0; k < columnLength; ++k)
                                            {
                                                tableData[i][j].IsColumnEnables[k] = EditorGUILayout.BeginToggleGroup(
                                                    "Enable",
                                                    tableData[i][j].IsColumnEnables[k]);
                                                {
                                                    GUILayout.BeginVertical("box");
                                                    {
                                                        GUILayout.BeginHorizontal();
                                                        {
                                                            tableData[i][j].ColumnName[k] =
                                                                EditorGUILayout.TextField(tableData[i][j].ColumnName[k],
                                                                                          GUILayout.MaxWidth(104));
                                                            GUILayout.Space(4);
                                                            tableData[i][j].ColumnDescribes[k] =
                                                                EditorGUILayout.TextField(tableData[i][j].ColumnDescribes[k],
                                                                                          GUILayout.MaxWidth(286));
                                                            GUILayout.Space(4);
                                                            tableData[i][j].SQLite3Types[k] =
                                                                (SQLite3ValueType)
                                                                EditorGUILayout.EnumPopup(tableData[i][j].SQLite3Types[k],
                                                                                          GUILayout.MaxWidth(104));

                                                            //tableData[i][j].SQLite3Constraints[k] =
                                                            //    (SQLite3Constraint)
                                                            //        EditorGUILayout.EnumPopup(tableData[i][j].SQLite3Constraints[k],
                                                            //            GUILayout.MaxWidth(100));
                                                        }
                                                        GUILayout.EndHorizontal();
                                                        GUILayout.Space(10);
                                                        GUILayout.BeginHorizontal("box");
                                                        {
                                                            SQLite3Constraint constraint = tableData[i][j].SQLite3Constraints[k];
                                                            bool isPrimaryKey            = (constraint & SQLite3Constraint.PrimaryKey) != 0;
                                                            bool isAutoIncrement         = (constraint & SQLite3Constraint.AutoIncrement) != 0;
                                                            bool isNotNull = (constraint & SQLite3Constraint.NotNull) != 0;
                                                            bool isUnique  = (constraint & SQLite3Constraint.Unique) != 0;

                                                            EditorGUILayout.LabelField("SQLite3 Constraint:", leftTittleStyle, GUILayout.Width(114));
                                                            isPrimaryKey = EditorGUILayout.ToggleLeft("PrimaryKey", isPrimaryKey, GUILayout.Width(80));

                                                            if (tableData[i][j].SQLite3Types[k] != SQLite3ValueType.Integer)
                                                            {
                                                                GUI.enabled     = false;
                                                                isAutoIncrement = false;
                                                            }

                                                            isAutoIncrement = EditorGUILayout.ToggleLeft("AutoIncrement", isAutoIncrement, GUILayout.Width(104));
                                                            GUI.enabled     = true;

                                                            if (isPrimaryKey)
                                                            {
                                                                isUnique    = false;
                                                                isNotNull   = false;
                                                                GUI.enabled = false;
                                                            }
                                                            isNotNull   = EditorGUILayout.ToggleLeft("NotNull", isNotNull, GUILayout.Width(60));
                                                            isUnique    = EditorGUILayout.ToggleLeft("Unique", isUnique, GUILayout.Width(60));
                                                            GUI.enabled = true;
                                                            bool isDefault = !(isPrimaryKey || isAutoIncrement || isNotNull || isUnique);
                                                            isDefault = EditorGUILayout.ToggleLeft("Default", isDefault, GUILayout.Width(60));
                                                            if (isDefault)
                                                            {
                                                                isPrimaryKey = isAutoIncrement = isNotNull = isUnique = false;
                                                            }

                                                            if (isDefault)
                                                            {
                                                                constraint = SQLite3Constraint.Default;
                                                            }
                                                            else
                                                            {
                                                                constraint = constraint & ~SQLite3Constraint.Default;
                                                            }

                                                            if (isPrimaryKey)
                                                            {
                                                                for (int m = 0; m < columnLength; m++)
                                                                {
                                                                    tableData[i][j].SQLite3Constraints[m] &= ~SQLite3Constraint.PrimaryKey;
                                                                }
                                                                constraint |= SQLite3Constraint.PrimaryKey;
                                                            }
                                                            else
                                                            {
                                                                constraint = constraint & ~SQLite3Constraint.PrimaryKey;
                                                            }

                                                            if (isAutoIncrement)
                                                            {
                                                                constraint |= SQLite3Constraint.AutoIncrement;
                                                            }
                                                            else
                                                            {
                                                                constraint &= ~SQLite3Constraint.AutoIncrement;
                                                            }

                                                            if (isNotNull)
                                                            {
                                                                constraint |= SQLite3Constraint.NotNull;
                                                            }
                                                            else
                                                            {
                                                                constraint &= ~SQLite3Constraint.NotNull;
                                                            }

                                                            if (isUnique)
                                                            {
                                                                constraint |= SQLite3Constraint.Unique;
                                                            }
                                                            else
                                                            {
                                                                constraint &= ~SQLite3Constraint.Unique;
                                                            }

                                                            tableData[i][j].SQLite3Constraints[k] = constraint;
                                                        }
                                                        GUILayout.EndHorizontal();
                                                    }
                                                    GUILayout.EndVertical();
                                                }
                                                EditorGUILayout.EndToggleGroup();
                                            }

                                            EditorGUILayout.BeginHorizontal("box");
                                            {
                                                tableData[i][j].IsNeedCreateScript =
                                                    EditorGUILayout.ToggleLeft("Need create or update script?",
                                                                               tableData[i][j].IsNeedCreateScript, GUILayout.Width(258));
                                                GUILayout.Space(10);
                                                if (GUILayout.Button("Create", GUILayout.Width(242)))
                                                {
                                                    try
                                                    {
                                                        if (string.IsNullOrEmpty(dbPath))
                                                        {
                                                            EditorUtility.DisplayDialog("Tips", "Please select the storage location of the database.", "OK");
                                                        }
                                                        else
                                                        {
                                                            if (string.IsNullOrEmpty(scriptFolder))
                                                            {
                                                                EditorUtility.DisplayDialog("Tips", "Please select the storage location of the script.", "OK");
                                                            }
                                                            else
                                                            {
                                                                if (tableData[i][j].IsNeedCreateScript)
                                                                {
                                                                    ScriptWriter.Writer(string.Format("{0}{1}.cs", Path.Combine(dataPath, scriptFolder), tableData[i][j].TableName), ref tableData[i][j]);
                                                                }
                                                                SQLite3Creator.Creator(ref tableData[i][j], Path.Combine(dataPath, dbPath));

                                                                EditorUtility.DisplayDialog("Tips", "Convert excel to SQLite3 table finished.", "OK");

                                                                if (isSingleFile)
                                                                {
                                                                    Close();
                                                                }
                                                            }
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        EditorUtility.DisplayDialog("Error", "Convert excel to SQLite3 table has an error:" + ex.Message, "OK");
                                                    }
                                                }
                                            }
                                            EditorGUILayout.EndHorizontal();
                                        }
                                        EditorGUILayout.EndVertical();
                                    }
                                }
                                EditorGUILayout.EndVertical();
                            }
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }
            }
            EditorGUILayout.EndVertical();
        }