gpt4 book ai didi

java - Smartsheet Java API 引起讨论

转载 作者:行者123 更新时间:2023-12-02 08:56:29 26 4
gpt4 key购买 nike

尝试使用 Java API 以编程方式获取智能表中行的注释。当我使用 row.getDiscussions() 时,即使该行上存在注释,它也始终返回 null。

try 
{
Smartsheet CommericalSmartsheet = new SmartsheetBuilder().setAccessToken("*****************").build();
Sheet sheet = CommericalSmartsheet.sheetResources().getSheet(*************,null,null,null,null,null,null,null);
List<Row> rows = sheet.getRows();
System.out.println("Number of Rows: " + rows.size());
for(int x = 0; x<rows.size();x++)
{
System.out.println("Row #: " + x);
List<Discussion> discussions = rows.get(x).getDiscussions();
if (discussions != null)
{
System.out.println("Number of Discussions: " + rows.get(x).getDiscussions().size());
for(int y=0;y<discussions.size();y++)
{
List<Comment> comments = discussions.get(y).getComments();
for (int i=0;i<comments.size();i++)
{
String CommentText = comments.get(i).getText();
User createdBy = comments.get(i).getCreatedBy();
Date createdAt = comments.get(i).getCreatedAt();
System.out.println(createdBy.toString() + " " + createdAt.toString() + ": " + CommentText);
}
}
}
}
} catch (SmartsheetException ex) {
Logger.getLogger(TFSpush.class.getName()).log(Level.SEVERE, null, ex);
}

我的输出是

Number of Rows:  1026
Row #: 0
Row #: 1
Row #: 2
Row #: 3
Row #: 4
Row #: 5
Row #: 6
Row #: 7
Row #: 8
Row #: 9
Row #: 10
Row #: 11
Row #: 12
Row #: 13
Row #: 14

我不会让你觉得无聊,剩下的就数到 1026

最佳答案

请在获取工作表时尝试使用 SheetInclusion.DISCUSSIONS:

Set<SheetInclusion> inclusionSet = Collections.singleton(SheetInclusion.DISCUSSIONS);
Sheet sheet = CommericalSmartsheet.sheetResources().getSheet(*************,inclusionSet,null,null,null,null,null,null);

有关详细信息,请参阅 SheetResources.getSheet()方法,以及 SheetInclusion Enum在 SDK 文档中。

关于java - Smartsheet Java API 引起讨论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60458645/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com