play-excel is a very well written plugin of Play-framework for exporting excel from java objects.
I used this plugin for my requirement of generating the I18n supported xls with custom names. This blog will explain this in details so that I can use it later :).
Line# 4: will basically make the play-excel to take the rendering functionality in play. (you can also use xlsx instead of "xls")
Line# 5: Will set the exported filename to given name i.e. "downloadUsers.xls"
Line# 6&7: pick up the template from views/
That's it you are done. Happy coding :).2. public static void users() { 3. List
users = User.findAll(); 4. request.format = "xls"; 5. renderArgs.put("__FILE_NAME__", "downloadUsers.xls"); 6. String template = "users-" + Lang.get() + ".xls"; 7. renderTemplate(template, users); 8. }
Comments
Post a Comment