【问题标题】:How to specify column types in a google drive file?如何在谷歌驱动文件中指定列类型?
【发布时间】:2017-03-23 12:37:04
【问题描述】:

我在 Google Drive 中保存了一个文件(有关文档,请参阅 Google Drive Doc

File file = service.files().get("fileId").execute();

java.io.File fileContent = new java.io.File("path/file.csv");
FileContent mediaContent = new FileContent("text/csv", fileContent);

// Send the request to the API.
File updatedFile = service.files().update("fileId", file, mediaContent).execute();

问题是我的 CSV 文件中有字符串值,具有数字格式(例如 018),当将它们保存在 Google Drive 文件中时,它们被视为数值(所以我有 18 而不是 018 ).

是否可以指定列的类型?

【问题讨论】:

  • 我不确定您能做些什么。您可以尝试设置 Covert = true 但这会将您的文件转换为我认为可能会或可能不会做完全相同的事情的谷歌表格。我唯一能想到的就是在你的字符串 '018' 周围设置引号

标签: java google-drive-api


【解决方案1】:

我在每一行的开头添加了一个单引号 '。这会通知 Excel 不要将该值视为数字。
来源:how to write to csv with a leading zero?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-10
    • 1970-01-01
    • 1970-01-01
    • 2020-10-13
    • 1970-01-01
    • 2016-10-19
    相关资源
    最近更新 更多