/// <summary> /// updates a rows information based on the instance of dataname found in the worksheet /// </summary> /// <param name="worksheet"></param> /// <param name="rowNumber">The number of the row to be modified</param> /// <param name="newData"></param> public static void ModifyRowData(this GS2U_Worksheet worksheet, int rowNumber, Dictionary <string, string> newData) { if (worksheet.GetWorksheetSize().y < rowNumber) { Debug.Log("Worksheet is smaller than rowNumber to edit"); return; } ListFeed feed = worksheet.LoadListFeedWorksheet(); ListEntry row = (ListEntry)feed.Entries[rowNumber - 1]; foreach (var entry in newData) { bool found = false; foreach (ListEntry.Custom element in row.Elements) { if (element.LocalName.ToLower() == entry.Key.ToLower()) { element.Value = entry.Value; found = true; break; } } if (!found) { Debug.LogError("No field found for " + entry.Key); } } row.Update(); }
/// <summary> /// Deletes the first row found using nameID /// </summary> /// <param name="worksheet"></param> /// <param name="rowNumber">Row number to be removed</param> public static void DeleteRowData(this GS2U_Worksheet worksheet, int rowNumber) { if (worksheet.GetWorksheetSize().y < rowNumber) { Debug.Log("Worksheet is smaller than rowNumber to edit"); return; } if (rowNumber > 0) { ListFeed feed = worksheet.LoadListFeedWorksheet(); ListEntry row = (ListEntry)feed.Entries[rowNumber - 1]; row.Delete(); } else { Debug.Log("Invalid Row Number"); } }