如何在将电子表格上传到Google云端硬盘时为其设置区域设置?

时间:2018-03-15 11:42:27

标签: google-drive-api google-sheets-api

我正在使用this template将文件上传到GDrive:

File fileMetadata = new File();
fileMetadata.setName("My Report");
fileMetadata.setMimeType("application/vnd.google-apps.spreadsheet");
java.io.File filePath = new java.io.File("files/report.csv");
FileContent mediaContent = new FileContent("text/csv", filePath);
File file = driveService.files().create(fileMetadata, mediaContent)
    .setFields("id")
    .execute();
System.out.println("File ID: " + file.getId());

我尝试使用Google表格API并发送更新语言区域的请求:

List<Request> requests = Collections.singletonList(
        new Request().setUpdateSpreadsheetProperties(
                new UpdateSpreadsheetPropertiesRequest()
                        .setFields("locale")
                        .setProperties(
                                new SpreadsheetProperties()
                                        .setLocale("en_US")
                        )
        )
);
BatchUpdateSpreadsheetRequest requestBody = new BatchUpdateSpreadsheetRequest();
requestBody.setRequests(requests);
requestBody.setIncludeSpreadsheetInResponse(false);

Sheets.Spreadsheets.BatchUpdate updateLocaleRequest = sheets.spreadsheets().batchUpdate(spreadsheetId, requestBody);
BatchUpdateSpreadsheetResponse response = updateLocaleRequest.execute();

但我想在上传文件时设置区域设置

0 个答案:

没有答案