How can I read an Excel spreadsheet from COBOL?
Question ID : 120
Created on 2010-02-03 at 5:14 PM
Author : Veryant Support [email@example.com]
Online URL : http://support.veryant.com/support/phpkb/question.php?ID=120
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.
- Download the latest stable release of Apache POI from http://poi.apache.org/download.html
- 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
- Extract the attached zip file, readxls.zip, into a directory
- Compile with compreadxls.bat
- 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:
runreadxls.bat contains the following:
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