1

I am new jasperreport developper

I want to view excel report on web browser

My code is:

 final JasperReportBuilder jasperReportBuilder = ReportManager.getBasicReport("Ofis Durum Raporları", "", "");

  TextColumnBuilder < String > cityColumn = Columns.column("İl", "cityName", DynamicReports.type.stringType());
  TextColumnBuilder < String > townColumn = Columns.column("Avukatlık Ofisi", "townName", DynamicReports.type.stringType());
  TextColumnBuilder < String > stateColumn = Columns.column("Dosya Durumu", "fileState", DynamicReports.type.stringType());
  TextColumnBuilder < Long > countColumn = Columns.column("Dosya Sayısı", "fileCount", DynamicReports.type.longType());
  jasperReportBuilder.addColumn(cityColumn, townColumn, stateColumn, countColumn);
  jasperReportBuilder.setDataSource(Collections.synchronizedList(stateReportsDTO));


  response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
  response.setHeader("Content-disposition", "inline; filename=test.xlsx");
  try {
      OutputStream stream = response.getOutputStream();
      response.setHeader("Content-disposition", "inline; filename=test.xlsx");
      JasperPrint jasperPrint = jasperReportBuilder.toJasperPrint();

      JRXlsxExporter docxExporter = new JRXlsxExporter();
      docxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      docxExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, stream);
      docxExporter.exportReport();

      Response.ResponseBuilder responseBuilder = null;
      responseBuilder = Response.ok(stream);

But does not show up on web browser, it just downloads

if excel file show browser than i show excel file and that is not posible i run excel. Java Process class start with outputstream. Process class destination link : stackoverflow.com/questions/3774432/starting-a-process-in-java

Please do help me out here.

RAMAZAN CESUR
  • 317
  • 1
  • 3
  • 9
  • 1
    as far as I know there is no way by default to open excel in browser, just pdf, so this behavior is correct – quento Aug 11 '16 at 06:58
  • I that so either i run Process to outputstream to excel that is it posible – RAMAZAN CESUR Aug 11 '16 at 07:12
  • What is your question? – Alex K Aug 11 '16 at 07:25
  • My questions is if excel file show browser than i show excel file and that is not posible i run excel. Java Process class start with outputstream. Process class destination link : http://stackoverflow.com/questions/3774432/starting-a-process-in-java – RAMAZAN CESUR Aug 11 '16 at 07:42

0 Answers0