[英]How to insert an image to an excel file with xlsxwriter?
I have to write images with some other datas to an excel file in my Django project and I have tried the code below.我必须将带有一些其他数据的图像写入我的 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)
In this code, the "value" contains image's path.在此代码中,“值”包含图像的路径。 But I got errors such as
但是我遇到了错误,例如
warn("Image file '%s' not found." % force_unicode(filename))
Also I have tried to give the whole path such as C:/Users/username/..
but this time, I got an Permission Denied
error.此外,我尝试提供整个路径,例如
C:/Users/username/..
但这一次,我收到了Permission Denied
错误。
How can I fix this?我怎样才能解决这个问题?
I have worked on adding images using xlsxwriter.我一直在使用 xlsxwriter 添加图像。 But found few useful links which has similar issue and some information related to the same.
但是发现很少有有用的链接有类似的问题和一些与此相关的信息。
This_link_if_you_are_using_URL this_link_if_you_are_using_URL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.