/* This sample performs some simple * calculations using Excel. */ import excel.*; import java.io.*; import ezjcom.*; public class ExcelSample5 { public static void main(String args[]) { _Application app = null; try { // Instantiate an Excel App Global global = new Global(); // Retrieve the "Application", DO NOT set it visible app = (_Application) global.get_Global().getApplication().get_Application();; app.setVisible( false ); // Perform calculations and print results System.out.println( "Square root of 1729 is " + app.Evaluate( new JComVariant( "=SQRT(1729)" ))); System.out.println( "Roman for 1729 is " + app.Evaluate( new JComVariant( "=ROMAN(1729)" ))); System.out.println( "Cosine of 60 degrees is " + app.Evaluate( new JComVariant( "=COS(RADIANS(60))" ))); System.out.println( "The value of PI " + app.Evaluate( new JComVariant( "=PI()" ))); System.out.println( "Average of 4,4,6,8,10,22 is " + app.Evaluate( new JComVariant( "=AVERAGE(4,4,6,8,10,22)" ))); System.out.println( "Standard Deviation of 4,4,6,8,10,22 is " + app.Evaluate( new JComVariant( "=STDEV(4,4,6,8,10,22)" ))); } catch (Exception ex) { ex.printStackTrace(); } finally { // Quit the application if ( app != null ) try { app.Quit(); } catch (Exception ex) { // The catch is to make sure that if app.Quit throws an exception, // we still call JComShutdown! } // Shut down COM connections and release all resources. ezjcom.JComObject.JComShutdown(); } } }