0

我正在尝试使用 C#、Visual Studio 2017 连接到 smartsheet api。我正在尝试获取报告中单元格的历史记录,以便我可以绘制单元格中百分比值随时间变化的图表。

我在用 <package id="smartsheet-csharp-sdk" version="2.86.0" targetFramework="net461" />

我可以成功地进行 API 调用以获取工作表的单元格历史记录

        try
        {
            SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(apiToken).Build();
            PaginatedResult<CellHistory> results = smartsheet.SheetResources.RowResources.CellResources.GetCellHistory(
                sheetId,               // long sheetId
                rowId,                 // long rowId
                columnId,              // long columnId
                null,                  // IEnumerable<CellInclusion> includes
                null                   // PaginationParameters
                );

            textBox1.Text = ("Found " + results.TotalCount + " results");

            dataGridView2.Columns.Add("Date", "Date");
            dataGridView2.Columns.Add("Value", "Value");

            for (int i = 0; i < results.TotalCount; i++)
            {
                var index = dataGridView2.Rows.Add();
                dataGridView2.Rows[i].Cells["Date"].Value = (System.DateTime)results.Data[i].ModifiedAt;
                dataGridView2.Rows[i].Cells["Value"].Value = (double)results.Data[i].Value;
            }

        }
        catch (Exception ex)
        {
            textBox1.Text = ex.ToString();
        }

这很好用。

我试过使用 smartsheet.ReportResources 但它没有 RowRecources 。

如果我将相同的 SheetResources 代码指向报告,我会收到错误

Smartsheet.Api.ResourceNotFoundException: Not Found
   at Smartsheet.Api.Internal.AbstractResources.HandleError(HttpResponse response)
   at Smartsheet.Api.Internal.AbstractResources.ListResourcesWithWrapper[T](String path)
   at Smartsheet.Api.Internal.RowColumnResourcesImpl.GetCellHistory(Int64 sheetId, Int64 rowId, Int64 columnId, IEnumerable`1 include, PaginationParameters paging, Nullable`1 level)
   at Smartsheet.Api.Internal.RowColumnResourcesImpl.GetCellHistory(Int64 sheetId, Int64 rowId, Int64 columnId, IEnumerable`1 include, PaginationParameters paging)

有人可以帮助我如何在报告中获取单元格的历史吗?

4

1 回答 1

1

目前该 API 不提供任何读/写报告的支持。我建议使用工作表、工作表参考和公式来构建相同类型的报告。

然后您应该能够阅读这些表格并获取它们的历史记录。

于 2019-11-20T17:00:01.067 回答