|
dear all after greeting
i have problem with crystal reports with j2ee where i want to save the client reports choiced from list on the server where the report will be generated and its generated formats(as crystal report format) to save on the server and refresh the page that reponsible to the request how can i do that here my code for crystal report
//---------- Create a ReportClientDocument ------------- ReportClientDocument oReportClientDocument = new ReportClientDocument();
//---------- Set the path to the location of the report soruce ------------- //Open report. oReportClientDocument.open(reportName, 0);
//Get the report source IReportSource oReportSource = oReportClientDocument.getReportSource();
//Set the export options to export to the format of choice. ExportOptions oExportOptions = new ExportOptions(); oExportOptions.setExportFormatType(ReportExportFormat.crystalReports);
ReportExportControl oReportExportControl = new ReportExportControl();
//Pass the report source to the ReportExportControl and set the ExportOptions oReportExportControl.setReportSource(oReportSource); oReportExportControl.setExportOptions(oExportOptions);
oReportExportControl.setExportAsAttachment(false); //Pass the ConnectionInfo to the report to set the database username and password oReportExportControl.setDatabaseLogonInfos(oConnectionInfos);
//Pass Fields object to ReportExportControl oReportExportControl.setParameterFields(oFields); oReportExportControl.processHttpRequest(request, response,getServlet().getServletContext(), null); try { RequestContext re=new RequestContext(); InputStream in = oReportClientDocument.getReportSource().export(oExportOptions,re); OutputStream outt = new FileOutputStream("\\\\localhost\\d$\\"+reportname+".rpt"); byte[] buf = new byte[1024]; // Transfer bytes from in to out int len; while ((len = in.read(buf)) > 0) { outt.write(buf, 0, len); } in.close(); outt.close(); System.out.println("File copied."); ///////////////////////////////////////////// oReportExportControl.dispose(); response.reset(); ///////////////////////////////////////////// } catch (FileNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); System.out.println("in exception"); } } } catch(Exception e) { System.out.println(e); e.printStackTrace(); } }
so i want to save file without display to client the screen open or save or cancel also without it opened in client
if anyone know how is that please send the solution to me as soon as possible
thanks for all
|