List <FieldInfo> GetFields(string sheetName, ExcelRange sheetCells) { List <FieldInfo> fields = new List <FieldInfo>(); var fieldTypeCell = GetFieldTypeRowForSheet(sheetName); var fieldNameCell = GetFieldNameRowForSheet(sheetName); var nameRow = sheetCells["b" + fieldNameCell.Row + ":az" + fieldNameCell.Row]; foreach (var cell in nameRow) { FieldInfo fieldInfo; string cellAddress = GDEExcelDataHelper.GetExcelColumnName(cell.End.Column) + "1"; if (sheetCells[cellAddress].Text.Trim().ToLower().Equals(GDEExcelDataHelper.IgnoreToken)) { fieldInfo = new FieldInfo(); fieldInfo.skip = true; fields.Add(fieldInfo); } else if (!string.IsNullOrEmpty(cell.Text)) { cellAddress = GDEExcelDataHelper.GetExcelColumnName(cell.End.Column) + fieldTypeCell.Row; var typeCell = sheetCells[cellAddress]; ParseFieldType(typeCell.Text, out fieldInfo); fieldInfo.name = cell.Text.Trim(); fieldInfo.cellCol = GDEExcelDataHelper.GetExcelColumnName(cell.End.Column); fieldInfo.cellRow = cell.End.Row.ToString(); fields.Add(fieldInfo); } } return(fields); }
public static void DoExport(bool newSheet = false) { GDESettings settings = GDESettings.Instance; if (!GDEItemManager.FileChangedOnDisk(GDEItemManager.DataFilePath, settings.ExportFileMD5)) { Debug.Log("GDE Data hasn't changed, skipping export."); return; } if (settings.ExportType.Equals(ImportExportType.Local) && !string.IsNullOrEmpty(settings.ExportedLocalSpreadsheetName)) { // take the local languages dictionary // write it out to an excel file GDEExcelDataHelper excelHelper = new GDEExcelDataHelper(settings.ExportedLocalSpreadsheetName, true); excelHelper.ExportToSheet(GDEItemManager.ItemListBySchema); settings.ExportFileMD5 = File.ReadAllText(GDEItemManager.DataFilePath).Md5Sum(); } else if (settings.ExportType.Equals(ImportExportType.Google) && !string.IsNullOrEmpty(settings.ExportedGoogleSpreadsheetPath) && GDEDriveHelper.Instance.HasAuthenticated()) { GDEDriveHelper.Instance.GetSpreadsheetList(); string tempSheetPath = FileUtil.GetUniqueTempPathInProject() + "exportnewgoog_" + settings.ExportedGoogleSpreadsheetPath + ".xlsx"; GDEExcelDataHelper excelHelper = new GDEExcelDataHelper(tempSheetPath, true); excelHelper.ExportToSheet(GDEItemManager.ItemListBySchema); if (newSheet) { GDEDriveHelper.Instance.UploadNewSheet(tempSheetPath, settings.ExportedGoogleSpreadsheetPath); settings.ExportFileMD5 = File.ReadAllText(GDEItemManager.DataFilePath).Md5Sum(); } else { GDEDriveHelper.Instance.UploadToExistingSheet(settings.ExportedGoogleSpreadsheetPath, tempSheetPath); settings.ExportFileMD5 = File.ReadAllText(GDEItemManager.DataFilePath).Md5Sum(); } } else { var window = EditorWindow.GetWindow <GameDataEditor.GDEExportExcel>(true, GDEConstants.ExportSpreadsheetLbl); window.LoadSettings(); window.Show(); } }
static void ProcessSheet(string path) { try { GDEExcelDataHelper excelDataHelper = new GDEExcelDataHelper(path); excelDataHelper.OnUpdateProgress += delegate(string title, string msg, float progress) { EditorUtility.DisplayProgressBar(title, msg, progress); }; excelDataHelper.ProcessSheet(); } catch (Exception ex) { Debug.LogError(ex); } finally { EditorUtility.ClearProgressBar(); } }