imgeaslikok
imgeaslikok

Reputation: 626

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.

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.

How can I fix this?

Upvotes: 1

Views: 6901

Answers (1)

Python Bang
Python Bang

Reputation: 482

I have worked on adding images using xlsxwriter. But found few useful links which has similar issue and some information related to the same.

This_link_if_you_are_using_URL

Image_with_path

Similar_issue

Upvotes: 3

Related Questions