示例#1
0
        /*
         * TODO: Replace the body of this loop with your code
         * This *example* looks for rows with a "Status" column marked "Complete" and sets the "Remaining" column to zero
         *
         * Return a new Row with updated cell values, else null to leave unchanged
         */
        static Row evaluateRowAndBuildUpdates(Row sourceRow)
        {
            Row rowToUpdate = null;

            // Find cell we want to examine
            Cell statusCell = getCellByColumnName(sourceRow, "Status");

            if (statusCell.DisplayValue == "Complete")
            {
                Cell remainingCell = getCellByColumnName(sourceRow, "Remaining");
                if (remainingCell.DisplayValue != "0")                  // Skip if "Remaining" is already zero
                {
                    Console.WriteLine("Need to update row # " + sourceRow.RowNumber);
                    // We need to update this row, so create a rowBuilder and list of cells to update
                    var rowBuilder    = new Row.UpdateRowBuilder(sourceRow.Id);
                    var cellsToUpdate = new List <Cell>();

                    // Build each new cell value
                    var cellToUpdate = new Cell.UpdateCellBuilder(columnMap["Remaining"], 0).Build();   // Set value to 0

                    // Add to update list
                    cellsToUpdate.Add(cellToUpdate);
                    rowToUpdate = rowBuilder.SetCells(cellsToUpdate).Build();
                }
            }
            return(rowToUpdate);
        }
示例#2
0
        public virtual void TestUpdateRows()
        {
            server.setResponseBody("../../../TestSDK/resources/updateRows.json");

            Cell         cell1 = new Cell.UpdateCellBuilder(117, true).Build();
            Cell         cell2 = new Cell.UpdateCellBuilder(343, 99999999).Build();
            IList <Cell> cells = new List <Cell> {
                cell1, cell2
            };

            Row row  = new Row.UpdateRowBuilder(65654654).SetLocked(true).SetExpanded(true).SetCells(cells).Build();
            Row row2 = new Row.UpdateRowBuilder(4554684).SetToBottom(true).SetExpanded(false).Build();

            IList <Row> rows = sheetRowResource.UpdateRows(123, new List <Row> {
                row, row2
            });

            Assert.AreEqual(rows[1].ParentRowNumber, 1);
            Assert.AreEqual(rows[1].ParentId, 4624744004773764);
            Assert.AreEqual(rows[1].Expanded, true);
            Assert.AreEqual(rows[1].CreatedAt.Value.ToString(), DateTime.Parse("2015-01-09T11:41:55-08:00").ToString());
            Assert.AreEqual(rows[1].Cells[1].ColumnType, ColumnType.PICKLIST);
            Assert.AreEqual(rows[1].Cells[1].Value, rows[1].Cells[1].DisplayValue);
        }