public void DeleteInvoice(SpiceModel inv) { int row = 0; var range = $"{dataSheet}!A:D"; int j = 0; SpreadsheetsResource.ValuesResource.GetRequest request = service.Spreadsheets.Values.Get(SpreadsheetId, range); var response = request.Execute(); IList <IList <object> > values = response.Values; if (values != null && values.Count > 0) { foreach (var invoicerow in values) { j++; if (j > 1) { var Id = Int32.Parse(invoicerow[0].ToString()); if (Id == inv.Id) { row = j - 1; } } } } Request RequestBody = new Request() { DeleteDimension = new DeleteDimensionRequest() { Range = new DimensionRange() { SheetId = 461012880, Dimension = "ROWS", StartIndex = row, EndIndex = row + 1 } } }; List <Request> RequestContainer = new List <Request>(); RequestContainer.Add(RequestBody); BatchUpdateSpreadsheetRequest DeleteRequest = new BatchUpdateSpreadsheetRequest(); DeleteRequest.Requests = RequestContainer; SpreadsheetsResource.BatchUpdateRequest Deletion = new SpreadsheetsResource.BatchUpdateRequest(service, DeleteRequest, SpreadsheetId); Deletion.Execute(); }
public void UpdateInvoice(SpiceModel Spice) { int rowID = 0; var range = $"{dataSheet}!A:D"; int j = 0; SpreadsheetsResource.ValuesResource.GetRequest request = service.Spreadsheets.Values.Get(SpreadsheetId, range); var response = request.Execute(); IList <IList <object> > values = response.Values; if (values != null && values.Count > 0) { foreach (var invoicerow in values) { j++; if (j > 1) { var Id = Int32.Parse(invoicerow[0].ToString()); if (Id == Spice.Id) { rowID = j; } } } } var range2 = $"{dataSheet}!A{rowID}:D{rowID}"; var valueRange = new ValueRange(); var oblist = new List <object>() { Spice.Id, Spice.Name, Spice.Category1, Spice.Category2 }; valueRange.Values = new List <IList <object> > { oblist }; // Performing Update Operation... var updateRequest = service.Spreadsheets.Values.Update(valueRange, SpreadsheetId, range2); updateRequest.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED; var appendReponse = updateRequest.Execute(); }
public List <SpiceModel> Spices_GetList() { var myInvList = new List <SpiceModel>(); var range = $"{dataSheet}!A:D"; int j = 0; SpreadsheetsResource.ValuesResource.GetRequest request = service.Spreadsheets.Values.Get(SpreadsheetId, range); // Ecexuting Read Operation... var response = request.Execute(); // Getting all records from Column A to E... IList <IList <object> > values = response.Values; if (values != null && values.Count > 0) { foreach (var row in values) { j++; if (j > 0) { var myInv = new SpiceModel() { Id = Int32.Parse(row[0].ToString()), Name = row[1].ToString(), Category1 = row[2].ToString(), Category2 = row[3].ToString(), }; myInvList.Add(myInv); } } } else { Console.WriteLine("Error reading data."); } return(myInvList); }
/// <summary> /// Initializes a new instance of the <see cref="ResultService"/> class. /// </summary> /// <param name="result">A SPICE model reader result.</param> public ResultService(SpiceModel <Circuit, Simulation> result) { Result = result ?? throw new ArgumentNullException(nameof(result)); }