How can I read an Excel spreadsheet from COBOL?

Question ID : 120
Created on 2010-02-03 at 5:14 PM
Author : Veryant Support []

Online URL :

Here are the steps to compile and run the attached sample COBOL program (in which will read an Excel spreadsheet and display the contents. This sample uses Apache POI.

  1. Download the latest stable release of Apache POI from
  2. Extract the files into a directory. For example, download Apache POI 3.6 and extract the files to c: so you will have a directory named c:poi-3.6
  3. Extract the attached zip file,, into a directory
  4. Compile with compreadxls.bat
  5. Run READXLS with runreadxls.bat specifying a spreadsheet filename on the command line. For example "runreadxls readxls.xls".

compreadxls.bat contains the following two lines:

set CLASSPATH=c:poi-3.6poi-3.6-20091214.jar;%CLASSPATH%
iscc readxls.cbl

runreadxls.bat contains the following:

set CLASSPATH=c:poi-3.6poi-3.6-20091214.jar;%CLASSPATH%
iscrun READXLS %*

If you install POI in another location you simply need to modify the compile and run scripts.

To run READXLS without having to change CLASSPATH you could use the following command line:

java -cp "C:poi-3.6poi-3.6-20091214.jar;%CLASSPATH%" READXLS

Or if you want you can add C:poi-3.6poi-3.6-20091214.jar to your system CLASSPATH using the Control Panel : System : Advanced : Environment Variables dialog.

I think you will be able to see how to modify this sample to do what you need it to. If you need help please let our support team know.

Back to Original Question