在报告中发现“列ID”时出现问题

时间:2019-01-10 01:09:07

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

我希望能够通过API通过电子邮件发送报告,并且只通过特定的列发送一行。

API文档清楚地向您展示了如何通过电子邮件发送行,但是,我无法获取报告中的列ID来发送这些特定的列。我正在使用以下内容尝试输出列标题 Id 。标题将成功显示,但ID显示为空白。有这个原因吗?

else if(args[0].equalsIgnoreCase(MeatBotMain.prefix + "getuserroles")) {
            Guild server = event.getGuild();
            String userName = args[1];
            Member user = server.getMember(userName);
            List<Role> userRoles = user.getRoles();
        }

1 个答案:

答案 0 :(得分:4)

您应该致电 virtualId

 Console.WriteLine($"Title:{Col.Title} ID:{Col.VirtualId}");

基于https://smartsheet-platform.github.io/api-docs/#reportcolumn-object

  

报告列是“虚拟”列,因为它看起来与   源工作表列,但实际上是属于   那个报告。报告中的单元格通过其单元格引用此列   virtualColumnId属性,并从它们的实际列   源表通过其columnId属性。

基于https://smartsheet-platform.github.io/api-docs/?csharp#get-report

{
  "id": 4583173393803140,
  "name": "My Report",
  "totalRowCount": 4,
  "accessLevel": "OWNER",
  "permalink": "https://app.smartsheet.com/b/home?lx=pWNSDH9itjBXxBzFmyf-5w",
  "createdAt": "2012-07-24T18:22:29-07:00",
  "modifiedAt": "2012-07-24T18:30:52-07:00",
  "columns": [
    {
      "virtualId": 4583173393803140,
      "version": 0,
      "index": 0,
      "primary": true,
      "title": "Sheet Name",
      "type": "TEXT_NUMBER",
      "validation": false,
      "sheetNameColumn": true
    },
    {
      "virtualId": 2331373580117892,
      "version": 0,
      "index": 1,
      "title": "Status",
      "type": "TEXT_NUMBER",
      "validation": false
    }
  ],
  "rows": [
    {
      "id": 1732835527681924,
      "sheetId": 1060338138408836,
      "rowNumber": 1,
      "expanded": true,
      "accessLevel": "OWNER",
      "createdAt": "2014-10-02T15:05:35-07:00",
      "modifiedAt": "2014-10-02T15:05:35-07:00",
      "cells": [
        {
          "virtualColumnId": 4583173393803140,
          "type": "TEXT_NUMBER",
          "value": "My Sheet",
          "displayValue": "My Sheet"
        },
        {
          "columnId": 8467747974735748,
          "virtualColumnId": 2331373580117892,
          "type": "TEXT_NUMBER",
          "value": "In Progress",
          "displayValue": "In Progress"
        }
      ]
    }

  ]
}