/* This sample starts up a copy of Excel, * makes it visible, * puts the value "33" in cell A1, * and leaves Excel running for the user. */ import excel.*; import java.io.*; import ezjcom.*; public class ExcelSample1 { public static void main(String args[]) { try { // Instantiate an Excel App Global global = new Global(); // Retrieve the "_Application" interface, and set it visible _Application app = (_Application) global.get_Global().getApplication().get_Application(); app.setVisible( true ); // Add an initial workbook app.getWorkbooks().Add(); // Retrieve the active worksheet _Worksheet wks = (_Worksheet) app.getActiveSheet(); // Retrieve a Range that refers to the cell A1 Range range = wks.getRange( new JComVariant( "A1" )); // Set the value of the cell to "33" range.setValue( new JComVariant( 33 )); // Print the value of the cell System.out.println( range.getValue()); // Do not Quit the application, leave it running // for the user. } catch (JComException ex) { ex.printStackTrace(); } finally { // Shut down COM connections and release all resources. ezjcom.JComObject.JComShutdown(); } } }