Closed atestu closed 1 year ago
Interesting. Did you have a new line at the end of that comment? If you didn't, try adding it.
I can probably fix it by forcing a new line at the end of the insert.
The relevant code is here: https://github.com/caxlsx/caxlsx_rails/blob/fa1ad7c1fcba92adcf499dac0520b709137b1096/lib/axlsx_rails/template_handler.rb#L32
Yes, adding a new line after the comment works fine!
I came here to report this same bug. I'm in the process of upgrading an old Rails app, and I just upgraded from axlsx_rails 0.1.5 to caxlsx_rails 0.6.3 and spent a fair amount of time tracking this down.
The issue only seems to exist if the last line in your template is a comment. In this case, render_to_string returns an Axlsx::Worksheet rather than a string.
If you add a blank line after the comment, the issue goes away.
I'm glad to see this is already resolved!
@dwieringa Thanks for confirming the fix and contributing your comment.
It took me a while to figure this out so I thought I'd share in case someone like me searches everywhere for a solution to this weird problem.
When adding a comment at the end of a .axlsx file like so:
If you remove the last line, it works fine. If you keep it, it causes this error:
undefined method 'empty?' for #<Axlsx::Worksheet:0x0000000105d15dc0>
Full trace: