Moyosoft Products | Services | Download | Contact us    
Java Excel Connector
Products  >  Java Excel Connector  >  Getting started    
Getting started
This page presents an introduction to the Java Excel Connector product. You'll learn the basics on how to configure and use the library with your Java application.


You need three files to use the Java Excel Connector with your application. The downloaded package contains a folder named « lib ». This folder contains the necessary files described in detail below:

      These files contains all Java classes.

      You have to add the JAR files to your application's CLASSPATH. The CLASSPATH is the path that the Java runtime environment (JRE) searches for classes and other resource files.

      There are multiple ways to setup the CLASSPATH depending on your development environment. For example, you can specify the path to the JAR files in the command line when launching your application using the « -cp » option:

      > java -cp lib\jec-v1.2.4.jar;lib\moyocore.jar ...
      For more information about the CLASSPATH, have a look at Sun's documentation:

      This file contains all native code necessary to access the Excel application. This file has to be accessible by the Java runtime environment (JRE) in order to load the library. By default, native libraries are searched in locations defined by the « java.library.path » system property. You can define this property when launching your Java application like this:

      > java -Djava.library.path=./lib ...
      You can also define the path to this DLL file at runtime using Java code: Use the static method Excel.setLibraryPath(String path) before creating an instance of the Excel object.

Using the library

To follow this guide, please have a look at the minimal sample application: The starting point is creating an Excel object:
// Creating the Excel application object
Excel excel = new Excel();
Once you created the Excel object, you can access workbook, worksheets and cells.

Look at the JavaDoc for the listing of all Excel object's methods.

    Do not forget to call the method Excel.dispose() when you're done using all Excel objects. This is necessary to release native resources used by the library:

// Dispose the library

The Workbook object

You can either create a new workbook or open an existing workbook file:
// Creating a new workbook
Workbook workbook = excel.createWorkbook();

// Opening an existing workbook file
Workbook workbook = excel.openWorkbook(new File("My document.xls"));


A workbook contains multiple worksheets. You can add additional worksheets, remove them, or fill the worksheet's cells with data. By default, worksheets exist already in each workbook.
// Get the first active worksheet in the Excel workbook
Worksheet worksheet = workbook.getActiveWorksheet();

// Add a new worksheet to a workbook
Worksheet worksheet = new Worksheet(workbook);

// Get a list of all worksheets in the workbook
Worksheets worksheetsCollection = workbook.getWorksheets();
Once you have a Worksheet object, you can fill cells with data. A single cell or a range of cells is represented by the Range object:
// Fill the cell A1 with a text
worksheet.getCell(00).setValue("Hello !");

// Get a Range object for the first 5 cells of the column "A"
Range range = worksheet.getRange("A1:A5");


Creating charts is very easy. You can simply create a new Chart object:
// Create a new chart sheet in the workbook
Chart chart = new Chart(workbook);
You can set the chart's source data to any values in the worksheet represented by a Range object:
// Set the first column as a source for the chart's data 

How to go from here?

Now you have the necessary knowledge to start building your Java application using our product. For more detailed information, look at: