水晶报表系列文章 -- 用Swing方式显示报表

阅读更多

/*
 * Created on 2005/12/12
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.foobar;


import java.awt.*;

import javax.swing.*;

import com.crystaldecisions.ReportViewer.*;
//import com.crystaldecisions.reports.sdk.*;
//import com.crystaldecisions.sdk.occa.report.reportsource.IReportSource;
import com.crystaldecisions.sdk.occa.report.application.*;
import com.crystaldecisions.sdk.occa.report.reportsource.*;

/**
 * @author phss
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class TestSwing {
 private static void createAndShowGUI(){
  try{
   JFrame.setDefaultLookAndFeelDecorated(false);
   JFrame frame = new JFrame("TestSwing");
   frame.setTitle("Testing CRX1...");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   
   ReportViewerBean viewer = new ReportViewerBean();
   viewer.init(new String[0],null,null,null);
   System.err.println("--------------1----------");
   ReportClientDocument rpt = new ReportClientDocument();
   System.err.println("-------------2-----------");
   rpt.setReportAppServer("crmboe.mds-sn.com");
   //rpt.setReportAppServer("crmboe.ras.rptappserver");
   System.err.println("-------------3-----------");
   rpt.open("crmboe.ras.rptappserver://c:\\reports\\aa.rpt",0);
   //rpt.open("aa.rpt",0);
   System.err.println("--------------4----------");
   
   IReportSource rptSource = rpt.getReportSource();
   viewer.setReportSource(rptSource);
   System.err.println("--------------5----------");
   frame.getContentPane().add(viewer,BorderLayout.CENTER);
   frame.setSize(700,500);
   frame.setVisible(true);
   
   viewer.start();
   
   
  }catch(Exception e){
   e.printStackTrace();
  }
 }

 public static void main(String[] args) {
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      createAndShowGUI();
    }
  });
 }
}

你可能感兴趣的:(Swing,Go,C,C++,C#)