Google表格API v4未将null
值作为ValueRange
的一部分传递。
使用以下值创建ValueRange
时:
“测试A”,“测试B”,null,null,“测试E”
范围:
“A1:E1”
我得到以下结果:
A B C D E
1 Test A Test B Test E
但预期的结果是:
A B C D E
1 Test A Test B Test E
使用的API为spreadsheets().values().update(ID, range, ValueRange)
一种可能的解决方案是将ValueInputOption
设置为“USER_ENTERED”(如果尚未执行),但问题仍然存在。
以下是Java中的SSCCE:
public static void test(Sheets service, String id) {
String range = "A1:E1";
List<List<Object>> values = Arrays.asList(Arrays.asList("Test A", "Test B", null, null, "Test E"));
ValueRange vRange = new ValueRange();
vRange.setRange(range);
vRange.setValues(values);
try {
System.out.println(service.spreadsheets().values().update(id, range, vRange)
.setValueInputOption("USER_ENTERED").execute().toPrettyString());
} catch (IOException e) {
e.printStackTrace();
}
}
结果:
{
"spreadsheetId" : "[id]",
"updatedCells" : 3,
"updatedColumns" : 3,
"updatedRange" : "Sheet1!A1:C1",
"updatedRows" : 1
}
需要进行哪些更改才能识别null
,以便E最终会出现在E列中,而不是被浏览过的null
值?
答案 0 :(得分:1)
我遇到了类似的问题。
您可以使用 CREATE TABLE communications ( ID, TIME, STATUS ) AS
SELECT 636, DATE '2021-03-09' + INTERVAL '08:48:49' HOUR TO SECOND, 'new' FROM DUAL UNION ALL
SELECT 636, DATE '2021-03-10' + INTERVAL '10:47:31' HOUR TO SECOND, 'accepted' FROM DUAL UNION ALL
SELECT 636, DATE '2021-03-12' + INTERVAL '08:41:42' HOUR TO SECOND, 'new' FROM DUAL UNION ALL
SELECT 636, DATE '2021-03-12' + INTERVAL '09:43:49' HOUR TO SECOND, 'accepted' FROM DUAL;
CREATE TABLE responses( ID, TIME, STATUS ) AS
SELECT 636, DATE '2021-03-10' + INTERVAL '09:30:49' HOUR TO SECOND, 'displayed' FROM DUAL UNION ALL
SELECT 636, DATE '2021-03-11' + INTERVAL '07:48:49' HOUR TO SECOND, 'realized' FROM DUAL UNION ALL
SELECT 636, DATE '2021-03-12' + INTERVAL '10:28:49' HOUR TO SECOND, 'displayed' FROM DUAL UNION ALL
SELECT 636, DATE '2021-03-17' + INTERVAL '11:19:49' HOUR TO SECOND, 'realized' FROM DUAL;
(来自 Data.NULL_STRING
)而不是原生 Java com.google.api.client.util
。
帮我修好了