Play framework 1.2.x excel export with I18n and custom filename


play-excel is 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 render 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//users_.xls.

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.    }
That's it you are done. Happy coding :).

Comments

Popular posts from this blog

java.net.SocketException: Connection reset

Hide empty last column from Table/Tree Viewer

Spring: implements interface not working in @Controller