【问题标题】:How to use smartsheet API to get cell history in a report如何使用 smartsheet API 获取报告中的单元格历史记录
【发布时间】:2019-11-19 08:46:03
【问题描述】:

我正在尝试使用 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)

有人可以就如何在报告中获取单元格的历史记录提供一些帮助吗?

【问题讨论】:

  • 单元格历史记录仅在 /sheets 端点上可用。

标签: c# smartsheet-api smartsheet-api-2.0 smartsheet-c#-sdk-v2


【解决方案1】:

目前 API 不提供任何读取/写入报告的支持。我建议使用表格、表格引用和公式来构建相同类型的报告。

那么您应该能够阅读这些表格并获得它们的历史记录。

【讨论】:

    猜你喜欢
    • 2020-06-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-23
    • 2020-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-23
    相关资源
    最近更新 更多