zhangyu836 / xltpl

A python module to generate xls/x files from a xls/x template.
MIT License
71 stars 17 forks source link

image #11

Closed mufeng272933 closed 2 years ago

mufeng272933 commented 2 years ago

The image function in the example does not work.

zhangyu836 commented 2 years ago

xltpl uses xlrd to read and xlwt to write xls file. xlrd does not extract images, datavalidations or autofilter. xltpl uses openpyxl to read and write xlsx file. openpyxl uses Pillow to fetch image object. If Pillow not installed or Pillow can not locate image file. {%img v%} will be ignored.

mufeng272933 commented 2 years ago

I'm sure that pillow is installed, but the example don't work on my computer

zhangyu836 commented 2 years ago

Would you like to upload the generated files, and provide version numbers of the os, python, xltpl, openpyxl, pillow?

mufeng272933 commented 2 years ago

examples.zip This is my configuration and thank you.

zhangyu836 commented 2 years ago

It seems that the images other than the last one in the 'image' worksheet have been deleted or moved, causing {%img v%} to be ignored.

mufeng272933 commented 2 years ago

I am looking forward to your continuous improvement

zhangyu836 commented 2 years ago

{%img v%} must be in the first cell of the range covered by the image.

mufeng272933 commented 2 years ago

isn’t it right? I don't think I violated what you said

zhangyu836 commented 2 years ago

The first cell of the range covered by the image is the cell corresponding to the coordinates of the top-left of the image. It could be part of a merged cell, and is not visible. In such a case, you can unmerge the merged cell and move the variable to the appropriate cell.

mufeng272933 commented 2 years ago

in fact it's not a merged cell. I stretched it.

zhangyu836 commented 2 years ago

Upgrade your xltpl and retry.

mufeng272933 commented 2 years ago

it doesn't work either.

zhangyu836 commented 2 years ago

Upload your file. Let's see how to make it work.

mufeng272933 commented 2 years ago

xlstpl_test.zip

zhangyu836 commented 2 years ago

You need to insert an image as a reference so that xltpl can determine the position, size of the image to be generated.

mufeng272933 commented 2 years ago

I'm ready to give up. Maybe xlwings is also a good choice

zhangyu836 commented 2 years ago

ok

zhangyu836 commented 2 years ago

Inserted a reference image in Sheet1.

lo_info={'pic':pic} lo_info={'test':'test'}

changed to

lo_info={'pic':pic} lo_info['test'] = 'test'

xlstpl_test.zip

mufeng272933 commented 2 years ago

i'm sorry about that but it doesn't work.Thank you just the same.

At 2022-01-19 11:43:11, "Zhang Yu" @.***> wrote:

Inserted a reference image in Sheet1.

lo_info={'pic':pic} lo_info={'test':'test'}

changed to

lo_info={'pic':pic} lo_info['test'] = 'test'

xlstpl_test.zip

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>