简体   繁体   English

为什么将excel文件作为zip文件上传?

[英]Why are excel files uploaded as zip file?

I have an excel sheet called last_run.xlsx , and I use a small python code to upload it on slack, as follow: 我有一个名为last_run.xlsx的excel工作表,我使用一个小的python代码在slack上上传了它,如下所示:

import os
import slack

token= XXX
client = slack.WebClient(token=slack_token)

response = client.files_upload(
        channels="@viktor",
        file="last_run.xlsx")

But when I receive it on slack it is a weird zip file and not an excel file anymore... any idea what I do wrong? 但是,当我在闲置状态下收到它时,它是一个奇怪的zip文件,而不是一个excel文件……任何想法我做错了吗?

Excel files are actually zipped collection of XML documents. Excel文件实际上是压缩的XML文档集合。 So it appears that the automatic file detection of Slack is recognizing it as ZIP file for that reason. 因此,出于这种原因,似乎Slack的自动文件检测将其识别为ZIP文件。

Also manually specified xlsx as filetype does not change that behavior. 同样,手动将xlsx指定为filetype不会更改该行为。

What works is if you also specify a filename . 有效的是,如果您还指定filename Then it will be correctly recognized and uploaded as Excel file. 然后它将被正确识别并作为Excel文件上传。

Code: 码:

import os
import slack

client = slack.WebClient(token="MY_TOKEN")

response = client.files_upload(
        channels="@viktor",
        file="last_run.xlsx",
        filename="last_run.xlsx")

This looks like a bug in the automatic to me, so I would suggest to submit a bug report to Slack about this behavior. 在我看来,这似乎是自动程序中的错误,因此,我建议向Slack提交有关此行为的错误报告。

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

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