如何使用xlsxwriter将图像插入excel文件?

问题描述 投票:0回答:1

我必须在我的Django项目中将带有其他数据的图像写入excel文件,并且尝试了以下代码。

for counter_i, cost in enumerate(costs):
        counter_i += 1
        for counter_j, feature in enumerate(features):
            value = getattr(cost, feature)
            if feature == 'image':
                image = str(value)
                worksheet.insert_image(counter_i, counter_j, image, {'x_offset': 15, 'y_offset': 10})
            else:
                worksheet.write(counter_i, counter_j, value)

在此代码中,“值”包含图像的路径。但是我遇到了诸如

的错误

warn("Image file '%s' not found." % force_unicode(filename))

而且我也尝试给出整个路径,例如C:/Users/username/..,但是这次,我遇到了Permission Denied错误。

我该如何解决?

python django export-to-excel xlsxwriter
1个回答
0
投票

我已经使用xlsxwriter添加图像。但发现很少有类似问题的有用链接以及与之相关的一些信息。

This_link_if_you_are_using_URL

Image_with_path

Similar_issue

© www.soinside.com 2019 - 2024. All rights reserved.