private static bool IsValidSheet(EEWorksheet sheet)
        {
            if (sheet == null || sheet.RowCount <= EESettings.Current.TypeRowIndex || sheet.ColumnCount < 1)
            {
                return(false);
            }
            int validColumnCount = 0;

            for (int col = 0; col < sheet.ColumnCount; col++)
            {
                string varType = sheet.GetCellValue(EESettings.Current.TypeRowIndex, col);
                if (string.IsNullOrEmpty(varType) || varType.Equals(" ") || varType.Equals("\r"))
                {
                    continue;
                }
                if (IsSupportedColumnType(varType))
                {
                    string varName = sheet.GetCellValue(EESettings.Current.NameRowIndex, col);
                    if (!string.IsNullOrEmpty(varName))
                    {
                        validColumnCount++;
                    }
                }
            }

            return(validColumnCount > 0);
        }
        private static SheetData ToSheetDataRemoveEmptyColumn(EEWorksheet sheet)
        {
            var validNameColumns = new List <int>();

            for (var column = 0; column < sheet.ColumnCount; column++)
            {
                var cellValue = sheet.GetCellValue(EESettings.Current.NameRowIndex, column);
                if (!string.IsNullOrEmpty(cellValue))
                {
                    validNameColumns.Add(column);
                }
            }
            var validTypeColumns = new List <int>();

            for (var column = 0; column < validNameColumns.Count; column++)
            {
                var cellValue = sheet.GetCellValue(EESettings.Current.TypeRowIndex, validNameColumns[column]);
                if (IsSupportedColumnType(cellValue))
                {
                    validTypeColumns.Add(validNameColumns[column]);
                }
            }

            var sheetData = new SheetData();

            for (var i = 0; i < sheet.RowCount; i++)
            {
                var rowData = new List <string>();
                foreach (var c in validTypeColumns)
                {
                    var cell = sheet.GetCell(i, c);
                    rowData.Add(cell != null ? cell.value : "");
                }

                sheetData.Table.Add(rowData);
            }

            sheetData.RowCount    = sheet.RowCount;
            sheetData.ColumnCount = validTypeColumns.Count;

            return(sheetData);
        }
Beispiel #3
0
        private static bool IsValidSheet(EEWorksheet sheet)
        {
            if (sheet == null || sheet.rowCount <= EESettings.Current.TypeRowIndex + 1 || sheet.columnCount < 1)
            {
                return(false);
            }
            var name = sheet.GetCellValue(EESettings.Current.NameRowIndex + 1, 1);

            if (name != "ID")
            {
                return(false);
            }
            var tp = sheet.GetCellValue(EESettings.Current.TypeRowIndex + 1, 1);

            if (tp != "int")
            {
                return(false);
            }
            return(true);
        }
        public static void DrawCell(EEWorksheet sheet, int row, int column)
        {
            var cell = sheet.GetCell(row, column);

            if (cell != null)
            {
                switch (cell.type)
                {
                case CellType.TextField:
                    cell.value = EditorGUILayout.TextField(cell.value, EEGUIStyle.textFieldCell, GUILayout.MaxWidth(cell.width));
                    break;

                case CellType.Label:
                    EditorGUILayout.LabelField(cell.value, GUILayout.MaxWidth(cell.width));
                    break;

                case CellType.Popup:
                {
                    var selectIndex = cell.ValueSelected.IndexOf(cell.value);
                    if (selectIndex < 0)
                    {
                        selectIndex = 0;
                    }
                    selectIndex = EditorGUILayout.Popup(selectIndex, cell.ValueSelected.ToArray(),
                                                        GUILayout.MaxWidth(cell.width));
                    cell.value = cell.ValueSelected[selectIndex];
                    break;
                }
                }
            }
            else
            {
                var s = EditorGUILayout.TextField(sheet.GetCellValue(row, column));
                sheet.SetCellValue(row, column, s);
            }
        }