Closed alliedarmour closed 3 years ago
@alliedarmour Have you been able to make this work inside a simple ruby script with local files? And is this being run within a controller, or in sidekiq or something offline?
@alliedarmour Have you been able to make this work inside a simple ruby script with local files? And is this being run within a controller, or in sidekiq or something offline?
It's being run within a controller, really simple:
def export
@meals = Meal.all.order(day: :asc)
@clinic = @clinic_name
respond_to do |format|
format.xlsx { render xlsx: "export", filename: "SpeiseplanExport-#{Date.today}.xlsx" }
end
end
The file is locally present. At the moment it's running in development mode, but the version without the image is also running in production without problems. It's just that I can't get the image in.
I also tried setting the width and height explicitly but with no effect.
Did the deploy to production process optimize the image and make it an asset? I'm pretty sure it's location and name will change.
I didn't try the image export in production yet cause it doesn't run locally. In production, just the export WITHOUT the image is running. If I can make it work locally (in development), I will try it in production :).
@alliedarmour Try explicitly checking for the existence of the file. Make sure there isn't a hidden error.
@alliedarmour Try explicitly checking for the existence of the file. Make sure there isn't a hidden error.
Thanks for your answer. I checked the file and Rails tells me it exists:
img = Rails.root.join('app', 'assets', 'images', 'logo.jpg')
Returning:
"C:/Users/Admin/Desktop/NKBRFQualityManagement/app/assets/images/logo.jpg"
Checking for file:
File.exist?(img) (returns true)
File.file?(img) (returns true)
I guess I will just go without the image for now until I (or someone else) finds out what's happening there :D
Same issue here with Rails 5.2.3 on Windows 10. Running it under Ubuntu the images render great.
If anyone is willing, we need a test repo so this issue can be duplicated. Any volunteers?
@alliedarmour This may have been fixed by a recent pull request in caxlsx that fixed importing binary files. You could test this again.
This should have been addressed in the binary import changes in Caxlsx.
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:
I tried:
img = File.expand_path(Rails.root+'app/assets/images/icon_small.jpg')
and also like described in the examples:img = File.expand_path('../logo.jpg', __FILE__)
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