Search in sources :

Example 6 with InputStreamResponse

use of com.runwaysdk.mvc.InputStreamResponse in project geoprism-registry by terraframe.

the class TransitionEventController method exportExcel.

@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "export-excel")
public ResponseIF exportExcel(ClientRequestIF request, @RequestParamter(name = "typeCode", required = true) String typeCode, @RequestParamter(name = "startDate") String startDate, @RequestParamter(name = "endDate") String endDate) throws ParseException, IOException {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    Date sDate = startDate != null ? format.parse(startDate) : new Date();
    Date eDate = endDate != null ? format.parse(endDate) : new Date();
    return new InputStreamResponse(service.exportExcel(request.getSessionId(), typeCode, sDate, eDate), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "historical-report.xlsx");
}
Also used : InputStreamResponse(com.runwaysdk.mvc.InputStreamResponse) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Aggregations

InputStreamResponse (com.runwaysdk.mvc.InputStreamResponse)6 Endpoint (com.runwaysdk.mvc.Endpoint)5 JsonObject (com.google.gson.JsonObject)3 LocalizationExcelExporter (com.runwaysdk.localization.LocalizationExcelExporter)1 Request (com.runwaysdk.session.Request)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 JSONObject (org.json.JSONObject)1