为 Google 工作表 Java Api 中的文本单元格设置 http link
Set http link for text cell in Google Sheets Java Api
我想在 Google 工作表中插入带有超链接的单元格文本:
我试过这个 Java 代码:
values.add(new CellData()
.setUserEnteredValue(new ExtendedValue()
.setStringValue(get.getTitle())).setHyperlink(get.getUrl())
但我只得到没有超链接的文本。
我该如何实现?
A hyperlink this cell points to, if any. This field is read-only. (To set it, use a =HYPERLINK
formula in the userEnteredValue.formulaValue field.)
您不能为 ExtendedValue 对象设置多个属性,它只接受单个 属性 设置。所有属性都为单元格指向一个值,但唯一的区别是那些设置器确定单元格值的类型(布尔值、字符串、公式、数字、错误),因此您不能为单个单元格设置多个值,这就是为什么会出现错误((oneof),其中一个字段 'value' 已经设置 ).
这是新代码,您可以像这样添加超链接:
values.add(
new CellData()
.setUserEnteredValue(new ExtendedValue()
.setFormulaValue("=HYPERLINK(\"http://whosebug.com\",\"SO label\")")
);
我想在 Google 工作表中插入带有超链接的单元格文本:
我试过这个 Java 代码:
values.add(new CellData()
.setUserEnteredValue(new ExtendedValue()
.setStringValue(get.getTitle())).setHyperlink(get.getUrl())
但我只得到没有超链接的文本。 我该如何实现?
A hyperlink this cell points to, if any. This field is read-only. (To set it, use a
=HYPERLINK
formula in the userEnteredValue.formulaValue field.)
您不能为 ExtendedValue 对象设置多个属性,它只接受单个 属性 设置。所有属性都为单元格指向一个值,但唯一的区别是那些设置器确定单元格值的类型(布尔值、字符串、公式、数字、错误),因此您不能为单个单元格设置多个值,这就是为什么会出现错误((oneof),其中一个字段 'value' 已经设置 ).
这是新代码,您可以像这样添加超链接:
values.add(
new CellData()
.setUserEnteredValue(new ExtendedValue()
.setFormulaValue("=HYPERLINK(\"http://whosebug.com\",\"SO label\")")
);