Title: How can I read an Excel spreadsheet from COBOL?
Here are the steps to compile and run the attached sample COBOL program (in readxls.zip) 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 http://poi.apache.org/download.html
  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, readxls.zip, 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.
Authored by: Veryant Support on Wed, Feb 3rd, 2010 at 7:00 PM
This question has been viewed 12103 times so far.
Online URL: http://support.veryant.com/support/phpkb/question.php?ID=120

Powered by PHPKB Knowledge Base Software