Wiki source code of Project WONDER-Frameworks-ExcelGeneration
Version 5.1 by David Holt on 2009/06/09 18:43
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | == ExcelGeneration == | ||
| 2 | |||
| 3 | === Anjo Krank === | ||
| 4 | |||
| 5 | You need to override appendToResponse on your page and make it look similar to: | ||
| 6 | |||
| 7 | {{code}} | ||
| 8 | |||
| 9 | public void appendToResponse(WOResponse response, WOContext context) { | ||
| 10 | super.appendToResponse(response, context); | ||
| 11 | if(reportData != null) { | ||
| 12 | response.setContent(reportData); | ||
| 13 | reportData = null; | ||
| 14 | String fileName = "results.xls"; | ||
| 15 | response.setHeader("inline; filename=\"" + fileName + "\"", "content-disposition"); | ||
| 16 | response.setHeader("application/vnd.ms-excel", "content-type"); | ||
| 17 | enableExcel = false; | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | {{/code}} | ||
| 24 | |||
| 25 | Additionally from Anjo: | ||
| 26 | |||
| 27 | The idea behind ExcelGenerator ist that you can use - hopefully - the same HTML that you output anyway for your reporting tasks. In particular, you should be able to re-use DynaReporter HTML and you also need only a minimal amount of work to use D2W. | ||
| 28 | |||
| 29 | Sometimes, you might need to apply some xslt, but otherwise you don't need additional code and there is no "api" to learn. | ||
| 30 | |||
| 31 | It's just a wrapper to your tabular HTML and it kind of makes me wonder why there isn't already tool like it in the POI stuff. |