简体   繁体   English

Rails 6 Axlsx Excel Gem - 图像不显示

[英]Rails 6 Axlsx Excel Gem - Images not displaying

I don't know if it's my fault or if it just doesn't work with Rails 6, but my images in the file are not displaying:我不知道这是我的错还是它不适用于 Rails 6,但我在文件中的图像没有显示:

I tried:我试过:

img = File.expand_path(Rails.root+'app/assets/images/logo.jpg')

and also like described in the examples:并且也像示例中描述的那样:

img = File.expand_path('../logo.jpg', __FILE__)

sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
            image.start_at 5, 20
            image.end_at 7, 22
end

The image is found (at least I don't get an error for this) but the only thing I see in the generated file (the rest of the creation works fine) is:找到了图像(至少我没有收到错误),但我在生成的文件中看到的唯一内容(其余的创建工作正常)是:

在此处输入图片说明

Could it be the image size not fitting in the cells?可能是图像大小不适合单元格吗? Or is it resizing automatically?还是自动调整大小?

Any suggestions or ideas?有什么建议或想法吗? I don't know what's wrong or what else I could try我不知道出了什么问题,或者我还能尝试什么

Did you try setting height and width for the image?您是否尝试为图像设置高度和宽度? Have a look at this old answer https://stackoverflow.com/a/47982814/1796645 (potential duplicate question)看看这个旧答案https://stackoverflow.com/a/47982814/1796645 (潜在的重复问题)

If you found a bug, then you could report it in https://github.com/caxlsx/caxlsx/issues如果你发现了一个错误,那么你可以在https://github.com/caxlsx/caxlsx/issues报告它

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

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