BatchUpdateSpreadsheetRequest requestBody = new BatchUpdateSpreadsheetRequest();
requestBody.Requests = new List<Request>();
Request r = new Request();
requestBody.Requests.Add(r);
r.UpdateCells = new UpdateCellsRequest();
var gc = new GridCoordinate();
gc.ColumnIndex = 0;
gc.RowIndex = 0;
gc.SheetId = 0;
r.UpdateCells.Start = gc;
r.UpdateCells.Fields = "*";
r.UpdateCells.Rows = new List<RowData>();
//TODO:: loop through record set to update cell data (cd) with values to insert
SqlDataReader reader = default(SqlDataReader);
reader = o_cSQL.RunSPReturnDataReader("Shippments", 40997, sNow, sNow);
while (reader.Read())
{
var rd = new RowData();
r.UpdateCells.Rows.Add(rd);
rd.Values = new List<CellData>();
var cd = new CellData();
cd.UserEnteredValue = new ExtendedValue();
// the next line is only updating the first cell (first row/first column)
//how to you get multiple CellData created for a single row ?
cd.UserEnteredValue.StringValue = reader["new_attn"].ToString();
rd.Values.Add(cd);
}
SpreadsheetsResource.BatchUpdateRequest batchRequest = service.Spreadsheets.BatchUpdate(requestBody, spreadsheetId);
batchRequest.Execute();
Can someone please help with how you get multiple cells updated per row? I know I'm only showing one value from my 'reader' from the database, that's where I got stuck in that I don't know how to specifically pinpoint each cell of my spreadsheet. I'm pulling an unknown recordset size from a database and need to enter it on a google spreadsheet. I know how many columns.
since I know my columns, I just kept making new CellData(); items for each RowData item in my reader.Read() while loop. Worked first time!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.