Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: crystal report with java Post Reply Post New Topic
Author Message
walid_s23
Newbie
Newbie


Joined: 10 Nov 2009
Location: Egypt
Online Status: Offline
Posts: 1
Quote walid_s23 Replybullet Topic: crystal report with java
     Posted: 10 Nov 2009 at 10:42pm
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
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum