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 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); } }