繁体   English   中英

将 Excel 转换为 Google 电子表格

[英]Conver Excel to Google Spreadsheet

我有 excel 文件,它包含一张包含图像的表格。 我需要使用 python 将此 excel 文件转换为 google 电子表格。

我可以使用 api 创建谷歌电子表格并添加我的文本数据,但我无法添加图像。 这种方式不适合我。

但我可以生成包含图像的 excel 文件。 现在我需要将 excel 表导出到谷歌电子表格。

我该怎么做?

您可以使用 DRIVE API 方法将 Excel 文件转换为 Google 表格文件

您只需要知道fileId并指定选项convert=true

样本:

service.files().copy(fileId=file_id,convert=true, body={"title": "Chose a title"}).execute()

如果您的 excel 文件在您的本地磁盘上 - 将其上传到 Google 表格文件,如下所示:

file_metadata = {
    'name': 'Desired Name',
    'mimeType': 'application/vnd.google-apps.spreadsheet'
}
media = MediaFileUpload('files/myExcelFile.xls',
                        mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                        resumable=True)
file = drive_service.files().create(body=file_metadata,
                                    media_body=media,
                                    fields='id').execute()
print 'The converted file is on your Google Drive and has the Id: %s' % file.get('id')

更多信息在这里这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM