/*
  i-net software provides programming examples for illustration only, without warranty
  either expressed or implied, including, but not limited to, the implied warranties
  of merchantability and/or fitness for a particular purpose. This programming example
  assumes that you are familiar with the programming language being demonstrated and
  the tools used to create and debug procedures. i-net software support professionals
  can help explain the functionality of a particular procedure, but they will not modify
  these examples to provide added functionality or construct procedures to meet your
  specific needs.
  © i-net software 1998-2010
*/

package samples.viewer;

import com.inet.report.Listener;
import com.inet.viewer.SwingViewerContext;
import com.inet.viewer.URLRenderData;

/** 
 * This sample shows you how you can export an report without the preview in the viewer.
 * An export dialog will pop up and then the report will be exported to the file you choose.
 */
public class ExportWithoutPreview {
    /*
     * Note: This listener is only started for example purposes, since the viewer requires some form of
     * report server or source of data. In your own application, you'd most likely already have a
     * report server and would simply change the URL given to URLRenderData.
     * 
     * This starts a listener on localhost, port 9000.
     */
    private static final Listener LISTENER = new Listener(9000);

	private URLRenderData renderConnection;   // This is our main render data connection - the source of our raw report data coming from our report server
    
	/**
	 * Exports an report without the preview in the viewer.
	 */
	public ExportWithoutPreview() {
        try {  
	          // we initialize the render data connection (assuming the URL is correct)
	   		  renderConnection = new URLRenderData( LISTENER.getUrlString()+
	   		                  "/?report=file:c:/test.rpt" );
              // If you use your own i-net Clear Reports server then use the report URL for this server, e.g.:
	          // renderConnection.setReportURL ( "http://serverName:9000/?report=file:c:/java/sample.rpt" ); 
	   		  
	   		  SwingViewerContext swingViewerContext = new SwingViewerContext();
	      
              // export report to desired file
	   		  swingViewerContext.export( null, renderConnection );
            
         } catch(Exception e) { e.printStackTrace(); }
    }
     
	/**
     * Main method of this sample
     * @param args arguments not used
     */
	public static void main(String [] args ) {
  		new ExportWithoutPreview(); 
    }
}
