Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用JAVA sheets API在google sheet中标识单元格类型(公式、列表等';)_Java_Google Sheets Api - Fatal编程技术网

使用JAVA sheets API在google sheet中标识单元格类型(公式、列表等';)

使用JAVA sheets API在google sheet中标识单元格类型(公式、列表等';),java,google-sheets-api,Java,Google Sheets Api,下面的代码检索特定范围内单元格的字符串表示形式。 我想要实现的是获取一个cell对象并识别值类型,如果它是公式,那么公式是什么,如果它是从etc'获取值的列表 ValueRange response = service.spreadsheets().values() .get(spreadsheetId, range) .execute(); List<List<Object>> values = respo

下面的代码检索特定范围内单元格的字符串表示形式。 我想要实现的是获取一个cell对象并识别值类型,如果它是公式,那么公式是什么,如果它是从etc'获取值的列表

    ValueRange response = service.spreadsheets().values()
            .get(spreadsheetId, range)
            .execute();
    List<List<Object>> values = response.getValues();
    if (values == null || values.isEmpty()) {
        System.out.println("No data found.");
    } else {
        for (List row : values) {
            System.out.println(row);
        }
    }
ValueRange响应=service.spreadsheets().values()
.get(电子表格ID,范围)
.execute();
列表值=response.getValues();
if(values==null | | values.isEmpty()){
System.out.println(“未找到数据”);
}否则{
用于(列表行:值){
系统输出打印项次(行);
}
}
想出了怎么做。。。 我只需要使用setIncludeGridData调用getValues()(true)


你有没有尝试过什么来实现你想要的?如果是,请将代码与您的问题一起发布。
    Sheets.Spreadsheets.Get get = service.spreadsheets().get(spreadsheetId).setIncludeGridData(true);
    Spreadsheet sheet = get.execute();
    GridData gridData = sheet.getSheets().get(0).getData().get(0);
    List<RowData> rowData = gridData.getRowData();
    System.out.println("Found " + rowData.size() + " rows in sheet range");
  {
    "effectiveFormat": {
      "backgroundColor": {
        "blue": 1.0,
        "green": 1.0,
        "red": 1.0
      },
      "horizontalAlignment": "RIGHT",
      "hyperlinkDisplayType": "PLAIN_TEXT",
      "padding": {
        "bottom": 2,
        "left": 3,
        "right": 3,
        "top": 2
      },
      "textFormat": {
        "bold": false,
        "fontFamily": "arial,sans,sans-serif",
        "fontSize": 10,
        "foregroundColor": {

        },
        "italic": false,
        "strikethrough": false,
        "underline": false
      },
      "verticalAlignment": "BOTTOM",
      "wrapStrategy": "OVERFLOW_CELL"
    },
    "effectiveValue": {
      "numberValue": 122.0
    },
    "formattedValue": "122",
    "userEnteredValue": {
      "formulaValue": "=SUM(A2:C2)"
    }
  }