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); }
public void AddWorksheet(string name) { var sheet = new EEWorksheet { name = name }; sheets.Add(sheet); }
public EEWorksheet AddWorksheet(string name) { var sheet = new EEWorksheet { name = name }; sheets.Add(sheet); return(sheet); }
private void OnGUI() { EEGUIStyle.Ensure(); try { if (_currentEeWorkbook != null) { EditorDrawHelper.DrawTableTab(_currentEeWorkbook, ref selectIndex); _currentEeWorksheet = _currentEeWorkbook.sheets[selectIndex]; EditorDrawHelper.DrawTable(_currentEeWorksheet); DrawMenus(); } } catch (Exception e) { EELog.LogError(e.ToString()); } }
public static void DrawTable(EEWorksheet sheet) { if (sheet == null) { return; } sheet.position = EditorGUILayout.BeginScrollView(sheet.position); for (var i = 0; i < sheet.RowCount; i++) { EditorGUILayout.BeginHorizontal(); for (var j = 0; j < sheet.ColumnCount; j++) { DrawCell(sheet, i, j); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); }
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); }
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); }
private static SheetData ToSheetData(EEWorksheet sheet) { var sheetData = new SheetData(); for (var i = 1; i <= sheet.rowCount; i++) { var rowData = new List <string>(); for (var j = 1; j <= sheet.columnCount; j++) { var cell = sheet.GetCell(i, j); rowData.Add(cell != null ? cell.value : ""); } sheetData.Table.Add(rowData); } sheetData.rowCount = sheet.rowCount; sheetData.columnCount = sheet.columnCount; return(sheetData); }
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); } }