Comments (10)
@straydogstudio I figured it out!!
xlsx = (render_to_string handlers: [:axlsx], formats: [:xlsx],
template: "report", layout: false)
attachments["#{subject}.xlsx"] = { mime_type: Mime::XLSX, content: xlsx }
mail(
to: [email protected],
from: "[email protected]",
subject: subject,
template_path: 'mailer',
template_name: "report"
)
The template in the xlsx block report
can't have the same name as the html template. So I had to rename it to
xlsx = (render_to_string handlers: [:axlsx], formats: [:xlsx],
template: "xls_report", layout: false)
attachments["#{subject}.xlsx"] = { mime_type: Mime::XLSX, content: xlsx }
It was always breaking on mail( ....)
, so I was thinking it might be getting the template names confused even when I wasn't attaching the xlsx file, so there it is 😄
from caxlsx_rails.
@straydogstudio any updates?
from caxlsx_rails.
Sorry @samuelshih I haven't been able to get to it. One way you could help is to create a simple Rails repo in Github that demonstrates the issue. Then I won't have to set that up, and it will make sure I have the setup you do (with the entire Gemfile.) Would you be willing to do that?
from caxlsx_rails.
Fantastic! That's great. I think I may know what that means then, but I'll have to check on that. Nice to have a simple solution!
from caxlsx_rails.
I'm going to leave this open as a reminder to look into this.
from caxlsx_rails.
Hey @straydogstudio , I also faced the same problem. It looks like rails are trying to surround the xlsx file with layouts:
To fix this problem I have to either rename the axlsx template or by passing render layout: false
, so my controller action looks like this:
respond_to do |format|
format.html
format.xlsx { render layout: false } # avoid surrounding xml with layout
end
I prefer the later one.
from caxlsx_rails.
@kikihakiem Thanks for the update. The format.xls really shouldn't come into play, as I don't register anything under that MIME type. But that is interesting.
What Rails / Axlsx / axlsx_rails versions do you have?
from caxlsx_rails.
Rails 4.2.4, axlsx 2.0.1, axlsx_rails 0.4.0
I'm using stdlib for format.xls
. However I got the same issue when generating xls file and the solution is also same, so I think it's rails issue.
from caxlsx_rails.
I have not been able to reproduce this bug. But, based on the experience of others (here and in other issues) the latest release of axlsx_rails (0.5.0) explicitly sets layout to false. Advising others to set the layout to false appears to fix these issues. I am cautiously optimistic. Please try 0.5.0 and comment on this issue (or open another) if the failure happens again.
from caxlsx_rails.
ref #29 (dupe)
from caxlsx_rails.
Related Issues (20)
- disposition: 'inline' is not working HOT 7
- iso-8601 dates are strange floating points? HOT 2
- File encrypted password in xlsx HOT 3
- secure-spreadsheet HOT 1
- no way to reload page after xlsx file is generated HOT 1
- Caxlsx examples link is broken in README HOT 2
- Is there anyway to render xlsx package object without template? HOT 2
- Align caxlsx dependency to support last version (3.1) HOT 4
- Travis build failing for Rails 6 HOT 6
- new line break on same column HOT 1
- Bug (potential security issue): XLSX content is included in body when `render nothing: true` is called HOT 1
- Question: Get formula value HOT 1
- Hide Row HOT 1
- Adding comments at the end of a .axlsx file causes an error HOT 4
- Fix typo in README; XslsMatchers
- 如何将我的附件( attachment ) 写入到xlsx表格当中,注意:不是图片 HOT 2
- Excel Displays Warning Modal When Using `add_hyperlink` Function HOT 1
- uninitialized constant Zip::OutputStream HOT 7
- unable to Open file with office 360 HOT 3
- Create frozen header row HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caxlsx_rails.