Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird encoding rendering .xlsx.axlsx template #59

Open
mikeLspohn opened this issue Aug 18, 2016 · 3 comments
Open

Weird encoding rendering .xlsx.axlsx template #59

mikeLspohn opened this issue Aug 18, 2016 · 3 comments
Labels

Comments

@mikeLspohn
Copy link

mikeLspohn commented Aug 18, 2016

I have a worker (tried from mailer alos) that renders an .xlsx.axlsx template and writes it to a Tempfile. I'm using this in one worker and it works perfectly. In another place I'm trying to user it that uses almost the same exact code, but it doesn't render the xlsx properly, it just writes out a file with 0 bytes. If I do a puts in the terminal from render 'path/to/template.xlsx.axlsx it outputs stuff but it looks like some encoding is wrong. I can see hints of xml in the obfuscated output, but something is definitely wrong.

Here's the code

    xls = render template: 'admin/raw_salary_reports/show.xlsx.axlsx', layout: false

    file = Tempfile.new(['position-salary-report', '.xlsx'], 'tmp')

    file.write(xls)

And here's the show.xlsx.axlsx file

wb = xlsx_package.workbook

wb.add_worksheet(name: 'Position Salary Reports') do |sheet|
  sheet.add_row ['Asset Size', 'Number Receiving', '75th Percentile', 'Median', '25th Percentile', 'Average']
  sheet.add_row []
end

gem 'axlsx', '2.1.0.pre'
gem 'axlsx_rails'
rails 4.2.6

@mikeLspohn
Copy link
Author

mikeLspohn commented Aug 18, 2016

I'm not sure what was up, but I got it working by doing what was mentioned in #55 using the Axlsx::Package.new and the p.to_stream. I would prefer not to do it this way if anyone knows how to fix this, but it works for now 😄

@straydogstudio
Copy link
Collaborator

Thanks for the update @mikeLspohn. Where is the "other" location where it fails? Is it in a controller action? Rake task? Script?

@mikeLspohn
Copy link
Author

Sorry, I never got back to you on this. It was in the context of a Resque job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants