www.infoZoom.de 
   

 home  company  jacoZoom  jadoZoom  dataZoom

 jacoZoom  download  buy  samples  support
jacoZoom - Java-COM-Bridge
jacoZoom Excel Automation Sample : JWinDoc.java

This sample demonstrates the automation of Excel using the excel automation object library and java wrapper classes which were generated with the jacoZoom-tool CreateJCW
The sample is part of the jacoZoom-download in form of the file TestExcel.java.

The following code snippet shows how it works.
  ...
  jcw.ms.Excel.Application excel = new jcw.ms.Excel.Application();
  excel.setVisible(true);
  ...
  Workbook bk = excel.getWorkbooks().add();
  Sheets shts = bk.getWorksheets();
  IDispatch disp = shts.add();
  // need call to getWorksheetFromUnknown, because Sheets.add returns IDispatch and not Worksheet
  _Worksheet sheet = Worksheet.getWorksheetFromUnknown(disp);
  sheet.getCells().setItem( new Variant(1),new Variant(1),new Variant("Hello world"));
  sheet.getCells().setItem( new Variant(2),new Variant(1),new Variant("This should be the second row"));
  ...
  bk.saveAs(new Variant("c:\\temp\\test.xls"));
  ...



The following screenshot shows what happens when the sample runs and setVisible(true) has been called: